Jaska 7 Posted March 23, 2022 (edited) I have a trouble understanding how dlsym works. My goal is to implement binary level localization for Delphi generated MachO (macOS and iOS) and ELF (Android and Linux) files. I have written classes to manipulate MachO and ELF files. Basically what I need to so is to find the symbols for resources (strings, forms and other resources). These symbols point to the resource segment in the file. The resource segment contain all the resources and their lengths. When writing the localized files I generate new resource segment data and then update the symbol values to point to the new address in the resource segment. As far as I know this is all I need to do. When I run the localized application, RTL calls dlsym to get the address where the symbol points. Now here is the problem. I expect dlsym to find the symbol, read the n_value and return it. Using a MachO viewer app I can see that the symbols' n_values have been updated and the resource segment also is updated. Still dlsym returns the old address. The same address that was the original value of the symbol's n_value (that no longer is there because it was overwritten during the localization process). So I believe that dlsym does not get the value it returns by locating the symbol and returning its n_value but there is some other section in the MachO file that also contains the same n_value and dlsym returns that. Is this the case? If it is what is this other section I need to update. Edited March 23, 2022 by Jaska Typo Share this post Link to post
Anders Melander 1782 Posted March 23, 2022 Are you patching the compiled binaries or are you generating resource modules for use with the RTL's built-in localization system? Share this post Link to post
Jaska 7 Posted March 23, 2022 I will do both. Just like I have done for Windows Share this post Link to post
Anders Melander 1782 Posted March 23, 2022 7 minutes ago, Jaska said: I will do both. Just like I have done for Windows Ah, I didn't realize who you represented. I'll let you figure it out for yourself then 🙂 Share this post Link to post
Jaska 7 Posted March 30, 2022 I got this working. In addition of patching the resource data and symbols you need to patch the symbol offsets in the export section of the dyld_info_only part. Share this post Link to post