Files
clang-p2996/lld/test/elf/Mips/dynlib-dynsym-micro.test
Rui Ueyama 33ab83bc4b ELF: Don't use LayoutPass.
Previously we applied the LayoutPass to order atoms and then
apply elf::ArrayOrderPass to sort them again. The first pass is
basically supposed to sort atoms in the normal fashion (which
is to sort symbols in the same order as the input files).
The second pass sorts atoms in {init,fini}_array.<priority> by
priority.

The problem is that the LayoutPass is overkill. It analyzes
references between atoms to make a decision how to sort them.
It's slow, hard to understand, and above all, it doesn't seem
that we need its feature for ELF in the first place.

This patch remove the LayoutPass from ELF pass list. Now all
reordering is done in elf::OrderPass. That pass sorts atoms by
{init,fini}_array, and if they are not in the special section,
they are ordered as the same order as they appear in the command
line. The new code is far easier to understand, faster, and
still able to create valid executables.

Unlike the previous layout pass, elf::OrderPass doesn't count
any attributes of an atom (e.g. permissions) except its
position. It's OK because the writer takes care of them if we
have to.

This patch changes the order of final output, although that's
benign. Tests are updated.

http://reviews.llvm.org/D7278

llvm-svn: 227666
2015-01-31 02:05:01 +00:00

209 lines
7.0 KiB
Plaintext

# 1. Check sorting of .dynsym content accordingly to .got section
# in case of using microMIPS relocations.
# 2. Check that microMIPS records in a dynamic symbol table have:
# - cleared the STO_MIPS_MICROMIPS flag
# - adjusted adress
# Build shared library
# RUN: yaml2obj -format=elf %s > %t.o
# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec -o %t-so %t.o
# RUN: llvm-readobj -dyn-symbols %t-so | FileCheck -check-prefix=CHECK-DYN %s
# Build shared library (yaml format)
# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \
# RUN: --output-filetype=yaml -o %t-yaml %t.o
# RUN: FileCheck -check-prefix=CHECK-GOT %s < %t-yaml
# CHECK-DYN: Format: ELF32-mips
# CHECK-DYN: Arch: mipsel
# CHECK-DYN: AddressSize: 32bit
# CHECK-DYN: LoadName:
# CHECK-DYN: DynamicSymbols [
# CHECK-DYN: Symbol {
# CHECK-DYN: Name: @ (0)
# CHECK-DYN: Value: 0x0
# CHECK-DYN: Size: 0
# CHECK-DYN: Binding: Local (0x0)
# CHECK-DYN: Type: None (0x0)
# CHECK-DYN: Other: 0
# CHECK-DYN: Section: Undefined (0x0)
# CHECK-DYN: }
# CHECK-DYN: Symbol {
# CHECK-DYN: Name: bar@ (5)
# CHECK-DYN: Value: 0x139
# CHECK-DYN: Size: 4
# CHECK-DYN: Binding: Global (0x1)
# CHECK-DYN: Type: Function (0x2)
# CHECK-DYN: Other: 0
# CHECK-DYN: Section: .text (0x4)
# CHECK-DYN: }
# CHECK-DYN: Symbol {
# CHECK-DYN: Name: foo@ (1)
# CHECK-DYN: Value: 0x121
# CHECK-DYN: Size: 24
# CHECK-DYN: Binding: Global (0x1)
# CHECK-DYN: Type: Function (0x2)
# CHECK-DYN: Other: 0
# CHECK-DYN: Section: .text (0x4)
# CHECK-DYN: }
# CHECK-DYN: Symbol {
# CHECK-DYN: Name: ext1@ (9)
# CHECK-DYN: Value: 0x0
# CHECK-DYN: Size: 0
# CHECK-DYN: Binding: Global (0x1)
# CHECK-DYN: Type: None (0x0)
# CHECK-DYN: Other: 0
# CHECK-DYN: Section: Undefined (0x0)
# CHECK-DYN: }
# CHECK-DYN: Symbol {
# CHECK-DYN: Name: ext2@ (14)
# CHECK-DYN: Value: 0x0
# CHECK-DYN: Size: 0
# CHECK-DYN: Binding: Global (0x1)
# CHECK-DYN: Type: None (0x0)
# CHECK-DYN: Other: 0
# CHECK-DYN: Section: Undefined (0x0)
# CHECK-DYN: }
# CHECK-DYN: ]
# CHECK-GOT: - type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2
# CHECK-GOT: section-choice: custom-required
# CHECK-GOT: section-name: .got
# CHECK-GOT: permissions: rw-
# CHECK-GOT: - type: got
# CHECK-GOT: content: [ 00, 00, 00, 80 ]
# CHECK-GOT: alignment: 2^2
# CHECK-GOT: section-choice: custom-required
# CHECK-GOT: section-name: .got
# CHECK-GOT: permissions: rw-
# CHECK-GOT: - ref-name: L000
# CHECK-GOT: type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2
# CHECK-GOT: section-choice: custom-required
# CHECK-GOT: section-name: .got
# CHECK-GOT: permissions: rw-
# CHECK-GOT: references:
# CHECK-GOT: - kind: LLD_R_MIPS_32_HI16
# CHECK-GOT: offset: 0
# CHECK-GOT: target: L007
# CHECK-GOT: - ref-name: L002
# CHECK-GOT: type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2
# CHECK-GOT: section-choice: custom-required
# CHECK-GOT: section-name: .got
# CHECK-GOT: permissions: rw-
# CHECK-GOT: references:
# CHECK-GOT: - kind: LLD_R_MIPS_32_HI16
# CHECK-GOT: offset: 0
# CHECK-GOT: target: L008
# CHECK-GOT: - ref-name: L004
# CHECK-GOT: type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2
# CHECK-GOT: section-choice: custom-required
# CHECK-GOT: section-name: .got
# CHECK-GOT: permissions: rw-
# CHECK-GOT: references:
# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT
# CHECK-GOT: offset: 0
# CHECK-GOT: target: foo
# CHECK-GOT: - ref-name: L005
# CHECK-GOT: type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2
# CHECK-GOT: section-choice: custom-required
# CHECK-GOT: section-name: .got
# CHECK-GOT: permissions: rw-
# CHECK-GOT: references:
# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT
# CHECK-GOT: offset: 0
# CHECK-GOT: target: ext1
# CHECK-GOT: - ref-name: L006
# CHECK-GOT: type: got
# CHECK-GOT: content: [ 00, 00, 00, 00 ]
# CHECK-GOT: alignment: 2^2
# CHECK-GOT: section-choice: custom-required
# CHECK-GOT: section-name: .got
# CHECK-GOT: permissions: rw-
# CHECK-GOT: references:
# CHECK-GOT: - kind: LLD_R_MIPS_GLOBAL_GOT
# CHECK-GOT: offset: 0
# CHECK-GOT: target: ext2
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32,
EF_MIPS_ARCH_32R2, EF_MIPS_MICROMIPS ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Size: 0x1C
- Name: .rel.text
Type: SHT_REL
Link: .symtab
AddressAlign: 0x04
Info: .text
Relocations:
- Offset: 0x00
Symbol: .rodata.str1
Type: R_MICROMIPS_GOT16
- Offset: 0x04
Symbol: .rodata.str1
Type: R_MICROMIPS_LO16
- Offset: 0x08
Symbol: .rodata.str2
Type: R_MICROMIPS_GOT16
- Offset: 0x0C
Symbol: .rodata.str2
Type: R_MICROMIPS_LO16
- Offset: 0x10
Symbol: foo
Type: R_MICROMIPS_CALL16
- Offset: 0x14
Symbol: ext1
Type: R_MICROMIPS_CALL16
- Offset: 0x18
Symbol: ext2
Type: R_MICROMIPS_CALL16
- Name: .rodata.str1
Type: SHT_PROGBITS
AddressAlign: 0x01
Size: 0x05
- Name: .rodata.str2
Type: SHT_PROGBITS
AddressAlign: 0x01
Size: 0x05
Symbols:
Local:
- Name: .text
Type: STT_SECTION
Section: .text
- Name: .rodata.str1
Type: STT_SECTION
Section: .rodata.str1
- Name: .rodata.str2
Type: STT_SECTION
Section: .rodata.str2
Global:
- Name: bar
Section: .text
Value: 0x18
Other: [ STO_MIPS_MICROMIPS ]
- Name: foo
Section: .text
Other: [ STO_MIPS_MICROMIPS ]
- Name: ext1
- Name: ext2
...