We didn't notice this earlier this we were only testing the export trie
encoded in a dylib, whose image base starts at zero. But a regular
executable contains __PAGEZERO, which means it has a non-zero image
base. This bug was discovered after attempting to run some programs that
performed dlopen on an executable.
Details
- Reviewers
smeenai - Group Reviewers
Restricted Project - Commits
- rGabd70fb3983f: [lld-macho] Export trie addresses should be relative to the image base
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM
lld/MachO/ExportTrie.h | ||
---|---|---|
36 | Nit: do we need this initialization, given that setImageBase should always be called? |
lld/MachO/ExportTrie.h | ||
---|---|---|
36 | I think it's good practice to zero-init fields that aren't initialized in the ctor. That way, if we forget to call setImageBase, we'll be more likely to get a deterministic error. |
lld/MachO/ExportTrie.h | ||
---|---|---|
36 | The flip side is that any tools which detect uninitialized memory wouldn't catch the issue. It doesn't seem like either ASan or UBSan can actually catch the uninitialized access right now though, so that's a purely academic concern :) |
lld/MachO/ExportTrie.h | ||
---|---|---|
36 | Ah, MSan is able to catch the uninitialized memory use, which is helpful. |
Nit: do we need this initialization, given that setImageBase should always be called?