[PATCH] D134571: [MachO] Support exports trie in both LC_DYLD_INFO and LC_DYLD_EXPORTS_TRIE
Daniel RodrÃguez Troitiño via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 14 10:02:14 PDT 2022
drodriguez added inline comments.
================
Comment at: llvm/lib/ObjCopy/MachO/MachOLayoutBuilder.cpp:255
+ }
+ assert((DyldInfoExportsTrieSize == 0 || DyldExportsTrieSize == 0) &&
+ "Export trie in both LCs");
----------------
beanz wrote:
> Hypothetically, without this assert does the code otherwise function to generate the export trie twice?
>
> The reason I'm asking, is that one of the original goals for the mach-o yaml tooling was to be able to construct invalid object files for testing purposes.
I think without this assert the export trie information will end up in two places in the binary.
If later a tool like MachOReader from ObjCopy, MachOObjectFile of Object, or macho2yaml tries to read that information, they all prefer the one in the DYLD_INFO vs. the one in EXPORTS_TRIE.
If I understood things correctly what determines whether one or the other exist should be the presence of chained fixups. With chained fixups, the DYLD_INFO does not need to be present, but then you need a place to put the exports trie, so the extra LC is used. Since the chained fixup API is marked as non-final and not to be relied on, I did not want to depend on it too heavily, so I used the presence of the EXPORTS_TRIE as a proxy.
I can remove the assert, but I think it is a nice help that something is being fishy.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134571/new/
https://reviews.llvm.org/D134571
More information about the llvm-commits
mailing list