[ELF] change LayoutBefore Reference to InGroup Reference

This makes it a lot easier for Section Group design.

llvm-svn: 200675
This commit is contained in:
Shankar Easwaran 2014-02-03 04:01:14 +00:00
parent 209bbb7774
commit 6e0e1bc859
9 changed files with 98 additions and 121 deletions

View File

@ -626,6 +626,7 @@ template <class ELFT> error_code ELFFile<ELFT>::createAtoms() {
}
ELFDefinedAtom<ELFT> *previousAtom = nullptr;
ELFDefinedAtom<ELFT> *inGroupAtom = nullptr;
ELFReference<ELFT> *anonFollowedBy = nullptr;
for (auto si = symbols.begin(), se = symbols.end(); si != se; ++si) {
@ -688,8 +689,6 @@ template <class ELFT> error_code ELFFile<ELFT>::createAtoms() {
anonAtom->setOrdinal(++_ordinal);
symbolData = ArrayRef<uint8_t>();
if (previousAtom)
createEdge(anonAtom, previousAtom, lld::Reference::kindLayoutBefore);
// If this is the last atom, let's not create a followon reference.
if (anonAtom && (si + 1) != se) {
anonFollowedBy = new (_readerStorage)
@ -715,13 +714,16 @@ template <class ELFT> error_code ELFFile<ELFT>::createAtoms() {
// Add a preceded-by reference only if the current atom is not a weak
// atom.
if (symbol->getBinding() != llvm::ELF::STB_WEAK)
createEdge(newAtom, previousAtom, lld::Reference::kindLayoutBefore);
createEdge(newAtom, inGroupAtom, lld::Reference::kindInGroup);
}
// The previous atom is always the atom created before unless the atom
// is a weak atom.
previousAtom = anonAtom ? anonAtom : newAtom;
if (!inGroupAtom)
inGroupAtom = previousAtom;
_definedAtoms._atoms.push_back(newAtom);
_symbolToAtomMapping.insert(std::make_pair(&*symbol, newAtom));
if (anonAtom)

View File

@ -10,6 +10,3 @@ CHECK: offset: 4
CHECK: - kind: R_HEX_B22_PCREL
CHECK: offset: 8
target:
CHECK: - kind: layout-before
CHECK: offset: 0
CHECK: target: fn1

View File

@ -6,7 +6,8 @@
# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec -o %t2 %t1
# RUN: llvm-objdump -t -disassemble %t2 | FileCheck -check-prefix RAW %s
# YAML: - ref-name: L003
# YAML: - ref-name: [[L002:[-a-zA-Z0-9_]+]]
# YAML: type: got
# YAML: content: [ 00, 00, 00, 00 ]
# YAML: alignment: 2^2
@ -16,8 +17,8 @@
# YAML: references:
# YAML: - kind: R_MIPS_32
# YAML: offset: 0
# YAML: target: L004
# YAML: - ref-name: L005
# YAML: target: [[L003:[-a-zA-Z0-9_]+]]
# YAML: - ref-name: [[L004:[-a-zA-Z0-9_]+]]
# YAML: type: got
# YAML: content: [ 00, 00, 00, 00 ]
# YAML: alignment: 2^2
@ -28,7 +29,7 @@
# YAML: - kind: R_MIPS_32
# YAML: offset: 0
# YAML: target: hidden
# YAML: - ref-name: L006
# YAML: - ref-name: [[L005:[-a-zA-Z0-9_]+]]
# YAML: type: got
# YAML: content: [ 00, 00, 00, 00 ]
# YAML: alignment: 2^2
@ -42,7 +43,7 @@
# YAML: - kind: R_MIPS_32
# YAML: offset: 0
# YAML: target: glob
# YAML: - ref-name: L007
# YAML: - ref-name: [[L006:[-a-zA-Z0-9_]+]]
# YAML: type: got
# YAML: content: [ 00, 00, 00, 00 ]
# YAML: alignment: 2^2
@ -53,37 +54,30 @@
# YAML: - kind: LLD_R_MIPS_GLOBAL_GOT
# YAML: offset: 0
# YAML: target: extern
# YAML: - ref-name: L008
# YAML: - ref-name: [[L007:[-a-zA-Z0-9_]+]]
# YAML: alignment: 2^2
# YAML: references:
# YAML: - kind: layout-after
# YAML: offset: 0
# YAML: target: glob
# YAML: - name: glob
# YAML: scope: global
# YAML: content: [ 00, 00, 84, 8F, 00, 00, 84, 24, 00, 00, 84, 8F,
# YAML: 00, 00, 84, 8F, 00, 00, 84, 8F ]
# YAML: alignment: 2^2
# YAML: references:
# YAML: - kind: R_MIPS_GOT16
# YAML: offset: 0
# YAML: target: L003
# YAML: - kind: R_MIPS_LO16
# YAML: offset: 4
# YAML: target: L004
# YAML: target: [[L003]]
# YAML: - kind: LLD_R_MIPS_GLOBAL_GOT16
# YAML: offset: 8
# YAML: target: L005
# YAML: target: [[L004]]
# YAML: - kind: R_MIPS_CALL16
# YAML: offset: 12
# YAML: target: L006
# YAML: target: [[L005]]
# YAML: - kind: R_MIPS_CALL16
# YAML: offset: 16
# YAML: target: L007
# YAML: - kind: layout-before
# YAML: offset: 0
# YAML: target: L008
# YAML: target: [[L006]]
# RAW: Disassembly of section .text:
# RAW: glob:

View File

@ -5,42 +5,48 @@ RUN: lld -flavor gnu -target x86_64 %p/Inputs/multiweaksyms.o \
RUN: --noinhibit-exec -static --output-filetype=yaml -o %t
RUN: FileCheck %s -check-prefix=WEAKSYMS < %t
WEAKSYMS: - ref-name: [[SYMA:[-a-zA-Z0-9_]+]]
WEAKSYMS: type: data
WEAKSYMS: - type: data
WEAKSYMS: alignment: 2^3
WEAKSYMS: references:
WEAKSYMS: - kind: layout-after
WEAKSYMS: target: [[SYMB:[-a-zA-Z0-9_]+]]
WEAKSYMS: offset: 0
WEAKSYMS: target: [[L001:[-a-zA-Z0-9_]+]]
WEAKSYMS: - name: myfn2
WEAKSYMS: scope: global
WEAKSYMS: type: data
WEAKSYMS: merge: as-weak
WEAKSYMS: alignment: 2^3
WEAKSYMS: references:
WEAKSYMS: - kind: layout-after
WEAKSYMS: target: [[SYMB]]
WEAKSYMS: - ref-name: [[SYMB]]
WEAKSYMS: offset: 0
WEAKSYMS: target: [[L001]]
WEAKSYMS: - ref-name: [[L001]]
WEAKSYMS: scope: global
WEAKSYMS: type: data
WEAKSYMS: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
WEAKSYMS: alignment: 2^3
WEAKSYMS: references:
WEAKSYMS: - kind: R_X86_64_64
WEAKSYMS: offset: 0
WEAKSYMS: target: test
WEAKSYMS: - kind: layout-before
WEAKSYMS: target: [[SYMA]]
WEAKSYMS: - kind: layout-after
WEAKSYMS: target: [[SYMC:[-a-zA-Z0-9_]+]]
WEAKSYMS: offset: 0
WEAKSYMS: target: [[L003:[-a-zA-Z0-9_]+]]
WEAKSYMS: - name: myfn1
WEAKSYMS: scope: global
WEAKSYMS: type: data
WEAKSYMS: merge: as-weak
WEAKSYMS: alignment: 2^3
WEAKSYMS: references:
WEAKSYMS: - kind: layout-after
WEAKSYMS: target: [[SYMC]]
WEAKSYMS: - ref-name: [[SYMC]]
WEAKSYMS: offset: 0
WEAKSYMS: target: [[L003]]
WEAKSYMS: - ref-name: [[L003]]
WEAKSYMS: scope: global
WEAKSYMS: type: data
WEAKSYMS: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
WEAKSYMS: alignment: 2^3
WEAKSYMS: references:
WEAKSYMS: - kind: R_X86_64_64
WEAKSYMS: offset: 0
WEAKSYMS: target: test
WEAKSYMS: - kind: layout-before
WEAKSYMS: target: [[SYMB]]

View File

@ -22,9 +22,6 @@ WEAKATOMSORDER: scope: global
WEAKATOMSORDER: content: [ 55, 48, 89, E5, BF, 00, 00, 00, 00, E8, 00, 00,
WEAKATOMSORDER: 00, 00, 5D, C3 ]
WEAKATOMSORDER: references:
WEAKATOMSORDER: - kind: layout-before
WEAKATOMSORDER: offset: 0
WEAKATOMSORDER: target: fn
WEAKATOMSORDER: - kind: layout-after
WEAKATOMSORDER: offset: 0
WEAKATOMSORDER: target: main
@ -37,9 +34,6 @@ WEAKATOMSORDER: - kind: R_X86_64_PC32
WEAKATOMSORDER: offset: 10
WEAKATOMSORDER: target: f
WEAKATOMSORDER: addend: -4
WEAKATOMSORDER: - kind: layout-before
WEAKATOMSORDER: offset: 0
WEAKATOMSORDER: target: [[CONSTSTRA]]
WEAKATOMSORDER: - ref-name: {{[0-9A-Z]+}}
WEAKATOMSORDER: references:
WEAKATOMSORDER: - kind: layout-after
@ -49,6 +43,3 @@ WEAKATOMSORDER: - name: f
WEAKATOMSORDER: scope: global
WEAKATOMSORDER: content: [ 55, 48, 89, E5, BF, 00, 00, 00, 00, E8, 00, 00,
WEAKATOMSORDER: 00, 00, 5D, C3 ]
WEAKATOMSORDER: references:
WEAKATOMSORDER: - kind: layout-before
WEAKATOMSORDER: offset: 0

View File

@ -8,24 +8,19 @@ RUN: FileCheck -check-prefix=WEAKATOMSORDER %s < %t2
WEAKORDER: 004001a4 T _start
WEAKATOMSORDER: - ref-name: [[TARGETA:[-a-zA-Z0-9_]+]]
WEAKATOMSORDER: alignment: 2^2
WEAKATOMSORDER: - kind: layout-after
WEAKATOMSORDER: offset: 0
WEAKATOMSORDER: target: [[TARGETB:[-a-zA-Z0-9_]+]]
WEAKATOMSORDER: - name: _start
WEAKATOMSORDER: target: [[TARGETC:[-a-zA-Z0-9_]+]]
WEAKATOMSORDER: - name: [[TARGETA:[-a-zA-Z0-9_]+]]
WEAKATOMSORDER: scope: global
WEAKATOMSORDER: merge: as-weak
WEAKATOMSORDER: alignment: 2^2
WEAKATOMSORDER: references:
WEAKATOMSORDER: - kind: layout-after
WEAKATOMSORDER: offset: 0
WEAKATOMSORDER: target: [[TARGETB]]
WEAKATOMSORDER: - ref-name: [[TARGETB]]
WEAKATOMSORDER: target: [[TARGETC]]
WEAKATOMSORDER: - ref-name: [[TARGETC]]
WEAKATOMSORDER: scope: global
WEAKATOMSORDER: content: [ C3 ]
WEAKATOMSORDER: alignment: 2^2
WEAKATOMSORDER: references:
WEAKATOMSORDER: - kind: layout-before
WEAKATOMSORDER: offset: 0
WEAKATOMSORDER: target: [[TARGETA]]

View File

@ -30,8 +30,6 @@ PLT: scope: global
PLT: references:
PLT: kind: R_X86_64_PC32
PLT: target: [[PLTNAME:[-a-zA-Z0-9_]+]]
PLT: kind: layout-before
PLT: target: __hey_1
PLT: name: main
PLT: scope: global

View File

@ -18,6 +18,3 @@ mergeAtoms: references:
mergeAtoms: - kind: R_X86_64_64
mergeAtoms: offset: 3
mergeAtoms: target: [[CONSTANT]]
mergeAtoms: - kind: layout-before
mergeAtoms: offset: 0
mergeAtoms: target: bar

View File

@ -30,9 +30,6 @@ ELF-i386: - kind: R_386_PC32
ELF-i386: offset: 17
ELF-i386: target: puts
ELF-i386: addend: 252
ELF-i386: - kind: layout-before
ELF-i386: offset: 0
ELF-i386: target: [[STRNAMEB]]
ELF-i386: undefined-atoms:
ELF-i386: - name: puts
ELF-i386: absolute-atoms: