[PATCH] D104919: [lld-macho] Preserve alignment for non-deduplicated cstrings
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 15:49:01 PDT 2021
thakis added a comment.
> I think it's fine actually -- in theory, cstrings can be reordered based on their literal values (instead of via symbol names) -- or at least that's what ld64's manpage suggests. In practice it doesn't actually seem to work.
Works for me:
thakis at MBP llvm-project % cat strings.cc
const char k1[] = "hi";
const char k2[] = "hallo";
extern "C" int puts(const char*);
int main() {
puts(k1);
puts(k2);
}
thakis at MBP llvm-project % clang strings.cc
thakis at MBP llvm-project % otool -s __TEXT __const a.out
a.out:
Contents of (__TEXT,__const) section
0000000100003fa2 68 69 00 68 61 6c 6c 6f 00
thakis at MBP llvm-project % clang strings.cc -Wl,-order_file,order.txt
thakis at MBP llvm-project % otool -s __TEXT __const a.out
a.out:
Contents of (__TEXT,__const) section
0000000100003fa2 68 61 6c 6c 6f 00 68 69 00
thakis at MBP llvm-project % cat order.txt
__ZL2k2
__ZL2k1
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104919/new/
https://reviews.llvm.org/D104919
More information about the llvm-commits
mailing list