[LLD][MachO] Fix a FIXME: Subtract base address from atom address when building

export trie.

llvm-svn: 248217
This commit is contained in:
Lang Hames 2015-09-21 22:06:02 +00:00
parent 963febd4f8
commit c803442890
3 changed files with 13 additions and 5 deletions

View File

@ -195,6 +195,9 @@ void MachOLinkingContext::configure(HeaderFileType type, Arch arch, OS os,
_pageZeroSize = 0x1000;
}
// Initial base address is __PAGEZERO size.
_baseAddress = _pageZeroSize;
// Make PIE by default when targetting newer OSs.
switch (os) {
case OS::macOSX:

View File

@ -1162,7 +1162,7 @@ void Util::addExportInfo(const lld::File &atomFile, NormalizedFile &nFile) {
}
Export exprt;
exprt.name = atom->name();
exprt.offset = _atomToAddress[atom]; // FIXME: subtract base address
exprt.offset = _atomToAddress[atom] - _ctx.baseAddress();
exprt.kind = EXPORT_SYMBOL_FLAGS_KIND_REGULAR;
if (atom->merge() == DefinedAtom::mergeAsWeak)
exprt.flags = EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION;

View File

@ -1,4 +1,4 @@
# RUN: lld -flavor darwin -arch x86_64 -macosx_version_min 10.8 -dylib \
# RUN: lld -flavor darwin -arch x86_64 -macosx_version_min 10.8 \
# RUN: %s %p/Inputs/libSystem.yaml -o %t && \
# RUN: llvm-objdump -exports-trie %t | FileCheck %s
#
@ -16,7 +16,7 @@ sections:
type: S_REGULAR
attributes: [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
address: 0x0000000000000000
content: [ 0xC3, 0xC3, 0xC3 ]
content: [ 0xC3, 0xC3, 0xC3, 0xC3 ]
global-symbols:
- name: _myHidden
type: N_SECT
@ -34,8 +34,13 @@ global-symbols:
sect: 1
desc: [ N_WEAK_DEF ]
value: 0x0000000000000002
- name: _main
type: N_SECT
scope: [ N_EXT ]
sect: 1
value: 0x0000000000000003
...
# CHECK-NOT: _myHidden
# CHECK: _myRegular
# CHECK: _myWeak [weak_def]
# CHECK: 0x00000FFD _myRegular
# CHECK: 0x00000FFE _myWeak [weak_def]