[lld] r182494 - [lld][LayoutPass] An earlier commit moved the functionality so that Atoms would
Shankar Easwaran
shankare at codeaurora.org
Wed May 22 10:41:04 PDT 2013
Author: shankare
Date: Wed May 22 12:41:04 2013
New Revision: 182494
URL: http://llvm.org/viewvc/llvm-project?rev=182494&view=rev
Log:
[lld][LayoutPass] An earlier commit moved the functionality so that Atoms would
be laid out by their ordinal overrides first, there was a bug that two atoms may
get the same override index due to which atoms were not ordered properly. This
commit fixes the problem.
Now the atoms are ordered by
- Section Position hints
- Atom override (Using layout-after/layout-before/in-group)
- Content Permissions
- Content Type
- File Ordinal
This also fixes the problem of running c++ static executables that
was broken by an earlier patch.
Modified:
lld/trunk/lib/Passes/LayoutPass.cpp
lld/trunk/test/elf/Hexagon/dynlib-gotoff.test
lld/trunk/test/elf/dynamic.test
lld/trunk/test/elf/ifunc.test
lld/trunk/test/elf/rodata.objtxt
lld/trunk/test/elf/x86-64-dynamic.test
Modified: lld/trunk/lib/Passes/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/LayoutPass.cpp?rev=182494&r1=182493&r2=182494&view=diff
==============================================================================
--- lld/trunk/lib/Passes/LayoutPass.cpp (original)
+++ lld/trunk/lib/Passes/LayoutPass.cpp Wed May 22 12:41:04 2013
@@ -31,6 +31,20 @@ bool LayoutPass::CompareAtoms::operator(
if (left == right)
return false;
+ // Sort by section position preference.
+ DefinedAtom::SectionPosition leftPos = left->sectionPosition();
+ DefinedAtom::SectionPosition rightPos = right->sectionPosition();
+
+ DEBUG(llvm::dbgs() << "Sorting by sectionPos"
+ << "(" << leftPos << "," << rightPos << ")\n");
+
+ bool leftSpecialPos = (leftPos != DefinedAtom::sectionPositionAny);
+ bool rightSpecialPos = (rightPos != DefinedAtom::sectionPositionAny);
+ if (leftSpecialPos || rightSpecialPos) {
+ if (leftPos != rightPos)
+ return leftPos < rightPos;
+ }
+
DEBUG(llvm::dbgs() << "Sorting by override\n");
AtomToOrdinalT::const_iterator lPos = _layout._ordinalOverrideMap.find(left);
@@ -77,20 +91,6 @@ bool LayoutPass::CompareAtoms::operator(
// TO DO: Sort atoms in customs sections together.
- // Sort by section position preference.
- DefinedAtom::SectionPosition leftPos = left->sectionPosition();
- DefinedAtom::SectionPosition rightPos = right->sectionPosition();
-
- DEBUG(llvm::dbgs() << "Sorting by sectionPos"
- << "(" << leftPos << "," << rightPos << ")\n");
-
- bool leftSpecialPos = (leftPos != DefinedAtom::sectionPositionAny);
- bool rightSpecialPos = (rightPos != DefinedAtom::sectionPositionAny);
- if (leftSpecialPos || rightSpecialPos) {
- if (leftPos != rightPos)
- return leftPos < rightPos;
- }
-
// Sort by .o order.
const File *leftFile = &left->file();
const File *rightFile = &right->file();
@@ -392,7 +392,7 @@ void LayoutPass::buildOrdinalOverrideMap
}
}
} else {
- _ordinalOverrideMap[atom] = index;
+ _ordinalOverrideMap[atom] = index++;
}
}
}
Modified: lld/trunk/test/elf/Hexagon/dynlib-gotoff.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Hexagon/dynlib-gotoff.test?rev=182494&r1=182493&r2=182494&view=diff
==============================================================================
--- lld/trunk/test/elf/Hexagon/dynlib-gotoff.test (original)
+++ lld/trunk/test/elf/Hexagon/dynlib-gotoff.test Wed May 22 12:41:04 2013
@@ -82,6 +82,62 @@ CHECKGOTPLT: offset: 8
CHECKGOTPLT: - kind: R_HEX_B22_PCREL
CHECKGOTPLT: offset: 12
target: __plt_fn2
+ - name: .PLT0
+CHECKGOTPLT: type: stub
+CHECKGOTPLT: content: [ 00, 40, 00, 00, 1C, C0, 49, 6A, 0E, 42, 9C, E2,
+CHECKGOTPLT: 4F, 40, 9C, 91, 3C, C0, 9C, 91, 0E, 42, 0E, 8C,
+CHECKGOTPLT: 00, C0, 9C, 52 ]
+CHECKGOTPLT: alignment: 2^4
+CHECKGOTPLT: section-name: .plt
+CHECKGOTPLT: references:
+CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
+CHECKGOTPLT: offset: 0
+ target: __got0
+CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
+CHECKGOTPLT: offset: 4
+ target: __got0
+ - name: __plt_fn
+CHECKGOTPLT: type: stub
+CHECKGOTPLT: content: [ 00, 40, 00, 00, 0E, C0, 49, 6A, 1C, C0, 8E, 91,
+CHECKGOTPLT: 00, C0, 9C, 52 ]
+CHECKGOTPLT: alignment: 2^4
+CHECKGOTPLT: section-name: .plt
+CHECKGOTPLT: references:
+CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
+CHECKGOTPLT: offset: 0
+ target: __got_fn
+CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
+CHECKGOTPLT: offset: 4
+ target: __got_fn
+CHECKGOTPLT: addend: 4
+ - name: __plt_fn1
+CHECKGOTPLT: type: stub
+CHECKGOTPLT: content: [ 00, 40, 00, 00, 0E, C0, 49, 6A, 1C, C0, 8E, 91,
+CHECKGOTPLT: 00, C0, 9C, 52 ]
+CHECKGOTPLT: alignment: 2^4
+CHECKGOTPLT: section-name: .plt
+CHECKGOTPLT: references:
+CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
+CHECKGOTPLT: offset: 0
+ target: __got_fn1
+CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
+CHECKGOTPLT: offset: 4
+ target: __got_fn1
+CHECKGOTPLT: addend: 4
+ - name: __plt_fn2
+CHECKGOTPLT: type: stub
+CHECKGOTPLT: content: [ 00, 40, 00, 00, 0E, C0, 49, 6A, 1C, C0, 8E, 91,
+CHECKGOTPLT: 00, C0, 9C, 52 ]
+CHECKGOTPLT: alignment: 2^4
+CHECKGOTPLT: section-name: .plt
+CHECKGOTPLT: references:
+CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
+CHECKGOTPLT: offset: 0
+ target: __got_fn2
+CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
+CHECKGOTPLT: offset: 4
+ target: __got_fn2
+CHECKGOTPLT: addend: 4
- name: __got0
CHECKGOTPLT: type: got
CHECKGOTPLT: content: [ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
@@ -147,59 +203,3 @@ CHECKGOTPLT: target: fn2
CHECKGOTPLT: - kind: R_HEX_32
CHECKGOTPLT: offset: 0
target: .PLT0
- - name: .PLT0
-CHECKGOTPLT: type: stub
-CHECKGOTPLT: content: [ 00, 40, 00, 00, 1C, C0, 49, 6A, 0E, 42, 9C, E2,
-CHECKGOTPLT: 4F, 40, 9C, 91, 3C, C0, 9C, 91, 0E, 42, 0E, 8C,
-CHECKGOTPLT: 00, C0, 9C, 52 ]
-CHECKGOTPLT: alignment: 2^4
-CHECKGOTPLT: section-name: .plt
-CHECKGOTPLT: references:
-CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
-CHECKGOTPLT: offset: 0
- target: __got0
-CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
-CHECKGOTPLT: offset: 4
- target: __got0
- - name: __plt_fn
-CHECKGOTPLT: type: stub
-CHECKGOTPLT: content: [ 00, 40, 00, 00, 0E, C0, 49, 6A, 1C, C0, 8E, 91,
-CHECKGOTPLT: 00, C0, 9C, 52 ]
-CHECKGOTPLT: alignment: 2^4
-CHECKGOTPLT: section-name: .plt
-CHECKGOTPLT: references:
-CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
-CHECKGOTPLT: offset: 0
- target: __got_fn
-CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
-CHECKGOTPLT: offset: 4
- target: __got_fn
-CHECKGOTPLT: addend: 4
- - name: __plt_fn1
-CHECKGOTPLT: type: stub
-CHECKGOTPLT: content: [ 00, 40, 00, 00, 0E, C0, 49, 6A, 1C, C0, 8E, 91,
-CHECKGOTPLT: 00, C0, 9C, 52 ]
-CHECKGOTPLT: alignment: 2^4
-CHECKGOTPLT: section-name: .plt
-CHECKGOTPLT: references:
-CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
-CHECKGOTPLT: offset: 0
- target: __got_fn1
-CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
-CHECKGOTPLT: offset: 4
- target: __got_fn1
-CHECKGOTPLT: addend: 4
- - name: __plt_fn2
-CHECKGOTPLT: type: stub
-CHECKGOTPLT: content: [ 00, 40, 00, 00, 0E, C0, 49, 6A, 1C, C0, 8E, 91,
-CHECKGOTPLT: 00, C0, 9C, 52 ]
-CHECKGOTPLT: alignment: 2^4
-CHECKGOTPLT: section-name: .plt
-CHECKGOTPLT: references:
-CHECKGOTPLT: - kind: R_HEX_B32_PCREL_X
-CHECKGOTPLT: offset: 0
- target: __got_fn2
-CHECKGOTPLT: - kind: R_HEX_6_PCREL_X
-CHECKGOTPLT: offset: 4
- target: __got_fn2
-CHECKGOTPLT: addend: 4
Modified: lld/trunk/test/elf/dynamic.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/dynamic.test?rev=182494&r1=182493&r2=182494&view=diff
==============================================================================
--- lld/trunk/test/elf/dynamic.test (original)
+++ lld/trunk/test/elf/dynamic.test Wed May 22 12:41:04 2013
@@ -13,13 +13,13 @@ CHECK: kind: R_X86_64_PC32
CHECK: offset: 18
CHECK: target: [[PLTNAME:[-a-zA-Z0-9_]+]]
+CHECK: name: [[PLTNAME]]
+CHECK: type: stub
+
CHECK: type: got
CHECK: references:
CHECK: kind: R_X86_64_JUMP_SLOT
-CHECK: name: [[PLTNAME]]
-CHECK: type: stub
-
CHECK: shared-library-atoms:
CHECK: name: foo
CHECK: load-name: shared.so-x86-64
Modified: lld/trunk/test/elf/ifunc.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/ifunc.test?rev=182494&r1=182493&r2=182494&view=diff
==============================================================================
--- lld/trunk/test/elf/ifunc.test (original)
+++ lld/trunk/test/elf/ifunc.test Wed May 22 12:41:04 2013
@@ -30,12 +30,6 @@ PLT: references:
PLT: kind: R_X86_64_PC32
PLT: target: [[PLTNAME]]
-// Make sure there's a got entry with a IRELATIVE relocation.
-PLT: type: got
-PLT: references:
-PLT: kind: R_X86_64_IRELATIVE
-PLT: target: hey
-
// Make sure the target of main's relocation is a stub with a PC32 relocation.
// This relocation is to the got atom, but you can't really write that check in
// FileCheck.
@@ -44,6 +38,12 @@ PLT: type: stub
PLT: references
PLT: kind: R_X86_64_PC32
+// Make sure there's a got entry with a IRELATIVE relocation.
+PLT: type: got
+PLT: references:
+PLT: kind: R_X86_64_IRELATIVE
+PLT: target: hey
+
CHECK: name: hey
CHECK: scope: global
CHECK: type: resolver
Modified: lld/trunk/test/elf/rodata.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/rodata.objtxt?rev=182494&r1=182493&r2=182494&view=diff
==============================================================================
--- lld/trunk/test/elf/rodata.objtxt (original)
+++ lld/trunk/test/elf/rodata.objtxt Wed May 22 12:41:04 2013
@@ -4,6 +4,6 @@ RUN: llvm-objdump -section-headers %t1 |
RUN: lld -flavor gnu -target hexagon -o %t2 %p/Inputs/rodata-test.hexagon --noinhibit-exec
RUN: llvm-objdump -section-headers %t2 | FileCheck -check-prefix=hexagon %s
-i386: .rodata 00000004 0000000000000111 DATA
+i386: .rodata 00000004 0000000000000114 DATA
-hexagon: .rodata 00000004 0000000000000111 DATA
+hexagon: .rodata 00000004 0000000000000114 DATA
Modified: lld/trunk/test/elf/x86-64-dynamic.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/x86-64-dynamic.test?rev=182494&r1=182493&r2=182494&view=diff
==============================================================================
--- lld/trunk/test/elf/x86-64-dynamic.test (original)
+++ lld/trunk/test/elf/x86-64-dynamic.test Wed May 22 12:41:04 2013
@@ -18,17 +18,6 @@ CHECK: offset: 25
CHECK: target: [[GOTNAME:[-a-zA-Z0-9_]+]]
CHECK: addend: -4
-CHECK: name: [[GOTNAME]]
-CHECK: type: got
-CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
-CHECK: section-choice: custom-required
-CHECK: section-name: .got.dyn
-CHECK: permissions: rw-
-CHECK: references:
-CHECK: - kind: R_X86_64_GLOB_DAT
-CHECK: offset: 0
-CHECK: target: i
-
- name: .PLT0
CHECK: type: stub
CHECK: content: [ FF, 35, 00, 00, 00, 00, FF, 25, 00, 00, 00, 00,
@@ -64,6 +53,17 @@ CHECK: - kind: R_X86_64_
CHECK: offset: 12
target: .PLT0
CHECK: addend: -4
+CHECK: name: [[GOTNAME]]
+CHECK: type: got
+CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
+CHECK: section-choice: custom-required
+CHECK: section-name: .got.dyn
+CHECK: permissions: rw-
+CHECK: references:
+CHECK: - kind: R_X86_64_GLOB_DAT
+CHECK: offset: 0
+CHECK: target: i
+
CHECK:shared-library-atoms:
More information about the llvm-commits
mailing list