[PATCH] [mach-o] wire up a dylib's install-name in more places
kledzik at apple.com
kledzik at apple.com
Mon Jun 30 14:20:46 PDT 2014
One other thing to fix: If a dylib is built and there is no -install_name on the command line, whatever path is passed to -o should be used as the install name.
Also what case of multiple yaml docs in one test case file is not working (and leading you to use Inputs/ files)/
================
Comment at: lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp:349-353
@@ -348,1 +348,7 @@
+ // If creating a dylib, add LC_ID_DYLIB.
+ if (_file.fileType == llvm::MachO::MH_DYLIB) {
+ size += sizeof(dylib_command) + pointerAlign(_file.installName.size() + 1);
+ ++count;
+ }
+
----------------
LC_ID_DYLIB traditionally goes after the LC_SEGMENT commands. So, just move this code up in the function.
================
Comment at: lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp:713-729
@@ -706,1 +712,19 @@
+ // Add LC_ID_DYLIB command for dynamic libraries.
+ if (_file.fileType == llvm::MachO::MH_DYLIB) {
+ dylib_command *dc = reinterpret_cast<dylib_command*>(lc);
+ StringRef path = _file.installName;
+ uint32_t size = sizeof(dylib_command) + pointerAlign(path.size() + 1);
+ dc->cmd = LC_ID_DYLIB;
+ dc->cmdsize = size;
+ dc->dylib.name = sizeof(dylib_command); // offset
+ dc->dylib.timestamp = 0; // FIXME
+ dc->dylib.current_version = 0; // FIXME
+ dc->dylib.compatibility_version = 0; // FIXME
+ if (_swap)
+ swapStruct(*dc);
+ memcpy(lc + sizeof(dylib_command), path.begin(), path.size());
+ lc[sizeof(dylib_command) + path.size()] = '\0';
+ lc += size;
+ }
+
----------------
Same here. Move this up so LC_ID_DYLIB lands after LC_SEGMENT commands.
FYI, the timestamp should always be 1. The two _versions come from command line arguments.
http://reviews.llvm.org/D4348
More information about the llvm-commits
mailing list