[all-commits] [llvm/llvm-project] d64efe: [lld-macho] Remove symbols to `__mod_init_func` wi...
Daniel Bertalan via All-commits
all-commits at lists.llvm.org
Sat Jul 6 06:42:02 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d64efe42eb98af76ba4ba26f48d079713f513af9
https://github.com/llvm/llvm-project/commit/d64efe42eb98af76ba4ba26f48d079713f513af9
Author: Daniel Bertalan <dani at danielbertalan.dev>
Date: 2024-07-06 (Sat, 06 Jul 2024)
Changed paths:
M lld/MachO/Driver.cpp
M lld/MachO/Writer.cpp
M lld/test/MachO/init-offsets.s
A lld/test/MachO/invalid/init-offsets.s
Log Message:
-----------
[lld-macho] Remove symbols to `__mod_init_func` with `-init_offsets` (#97156)
When `-fixup_chains`/`-init_offsets` is used, a different section,
`__init_offsets` is synthesized from `__mod_init_func`. If there are any
symbols defined inside `__mod_init_func`, they are added to the symbol
table unconditionally while processing the input files. Later, when
querying these symbols' addresses (when constructing the symtab or
exports trie), we crash with a null deref, as there is no output section
assigned to them.
Just making the symbols point to `__init_offsets` is a bad idea, as the
new section stores 32-bit integers instead of 64-bit pointers; accessing
the symbols would not do what the programmer intended. We should
entirely omit them from the output. This is what ld64 and ld-prime do.
This patch uses the same mechanism as dead-stripping to mark these
symbols as not needed in the output. There might be nicer fixes than the
workaround, this is discussed in #97155.
Fixes https://github.com/llvm/llvm-project/pull/79894#issuecomment-1944092892
Fixes #94716
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list