mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
c21ea7e2f4
Linkers (ld.bfd/gold/lld) place the section header table at the very end. This allows tools to strip it, which is optional in executable/shared objects. In addition, if we add or section, the size of the section header table will change. Placing the section header table in the end keeps section offsets unchanged. yaml2obj currently places the section header table immediately after the program header. Follow what linkers do to make offset updating easier. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D67221 llvm-svn: 371074
173 lines
6.8 KiB
Plaintext
173 lines
6.8 KiB
Plaintext
# The binary blobs in this file were created like this:
|
|
# llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu Inputs/elf-relr-relocs1.s -o - | obj2yaml | grep Content:
|
|
|
|
# RUN: yaml2obj -docnum 1 %s \
|
|
# RUN: | llvm-readobj --relocations --raw-relr - \
|
|
# RUN: | FileCheck --check-prefix=RAW-LLVM1 %s
|
|
# RAW-LLVM1: Section (1) .relr.dyn {
|
|
# RAW-LLVM1-NEXT: 0x10D60
|
|
# RAW-LLVM1-NEXT: 0x103
|
|
# RAW-LLVM1-NEXT: 0x20000
|
|
# RAW-LLVM1-NEXT: 0xF0501
|
|
# RAW-LLVM1-NEXT: 0xA700550400009
|
|
# RAW-LLVM1-NEXT: }
|
|
|
|
# RUN: yaml2obj -docnum 1 %s \
|
|
# RUN: | llvm-readobj --relocations - \
|
|
# RUN: | FileCheck --check-prefix=LLVM1 %s
|
|
# LLVM1: Section (1) .relr.dyn {
|
|
# LLVM1-NEXT: 0x10D60 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x10D68 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x10DA0 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20000 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20040 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20050 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20080 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20088 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20090 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20098 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20210 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x202A8 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x202D8 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x202E8 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x202F8 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20308 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20358 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20360 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20368 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20380 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: 0x20390 R_X86_64_RELATIVE - 0x0
|
|
# LLVM1-NEXT: }
|
|
|
|
# RUN: yaml2obj -docnum 1 %s \
|
|
# RUN: | llvm-readelf -relocations -raw-relr - \
|
|
# RUN: | FileCheck --check-prefix=RAW-GNU1 %s
|
|
# RAW-GNU1: Relocation section '.relr.dyn' at offset 0x40 contains 5 entries:
|
|
# RAW-GNU1: 0000000000010d60
|
|
# RAW-GNU1-NEXT: 0000000000000103
|
|
# RAW-GNU1-NEXT: 0000000000020000
|
|
# RAW-GNU1-NEXT: 00000000000f0501
|
|
# RAW-GNU1-NEXT: 000a700550400009
|
|
|
|
# RUN: yaml2obj -docnum 1 %s \
|
|
# RUN: | llvm-readelf -relocations - \
|
|
# RUN: | FileCheck --check-prefix=GNU1 %s
|
|
# GNU1: Relocation section '.relr.dyn' at offset 0x40 contains 21 entries:
|
|
# GNU1: 0000000000010d60 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000010d68 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000010da0 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020000 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020040 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020050 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020080 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020088 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020090 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020098 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020210 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 00000000000202a8 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 00000000000202d8 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 00000000000202e8 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 00000000000202f8 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020308 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020358 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020360 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020368 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020380 0000000000000008 R_X86_64_RELATIVE
|
|
# GNU1-NEXT: 0000000000020390 0000000000000008 R_X86_64_RELATIVE
|
|
|
|
# elf-relr-relocs1.s
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_DYN
|
|
Machine: EM_X86_64
|
|
Entry: 0x0000000000001000
|
|
Sections:
|
|
- Name: .relr.dyn
|
|
Type: SHT_RELR
|
|
Flags: [ SHF_ALLOC ]
|
|
Address: 0x00000000000001C8
|
|
Link: .symtab
|
|
AddressAlign: 0x0000000000000001
|
|
Content: 600D0100000000000301000000000000000002000000000001050F00000000000900405005700A00
|
|
...
|
|
|
|
# RUN: yaml2obj -docnum 2 %s \
|
|
# RUN: | llvm-readobj --relocations --raw-relr - \
|
|
# RUN: | FileCheck --check-prefix=RAW-LLVM2 %s
|
|
# RAW-LLVM2: Section (1) .relr.dyn {
|
|
# RAW-LLVM2-NEXT: 0x10D60
|
|
# RAW-LLVM2-NEXT: 0x103
|
|
# RAW-LLVM2-NEXT: 0x20000
|
|
# RAW-LLVM2-NEXT: 0xF0501
|
|
# RAW-LLVM2-NEXT: 0x50400009
|
|
# RAW-LLVM2-NEXT: }
|
|
|
|
# RUN: yaml2obj -docnum 2 %s \
|
|
# RUN: | llvm-readobj --relocations - \
|
|
# RUN: | FileCheck --check-prefix=LLVM2 %s
|
|
# LLVM2: Section (1) .relr.dyn {
|
|
# LLVM2-NEXT: 0x10D60 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x10D64 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x10D80 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x20000 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x20020 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x20028 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x20040 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x20044 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x20048 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x2004C R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x20088 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x200D4 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x200EC R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: 0x200F4 R_386_RELATIVE - 0x0
|
|
# LLVM2-NEXT: }
|
|
|
|
# RUN: yaml2obj -docnum 2 %s \
|
|
# RUN: | llvm-readelf -relocations -raw-relr - \
|
|
# RUN: | FileCheck --check-prefix=RAW-GNU2 %s
|
|
# RAW-GNU2: Relocation section '.relr.dyn' at offset 0x34 contains 5 entries:
|
|
# RAW-GNU2: 00010d60
|
|
# RAW-GNU2-NEXT: 00000103
|
|
# RAW-GNU2-NEXT: 00020000
|
|
# RAW-GNU2-NEXT: 000f0501
|
|
# RAW-GNU2-NEXT: 50400009
|
|
|
|
# RUN: yaml2obj -docnum 2 %s \
|
|
# RUN: | llvm-readelf -relocations - \
|
|
# RUN: | FileCheck --check-prefix=GNU2 %s
|
|
# GNU2: Relocation section '.relr.dyn' at offset 0x34 contains 14 entries:
|
|
# GNU2: 00010d60 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00010d64 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00010d80 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00020000 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00020020 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00020028 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00020040 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00020044 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00020048 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 0002004c 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 00020088 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 000200d4 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 000200ec 00000008 R_386_RELATIVE
|
|
# GNU2-NEXT: 000200f4 00000008 R_386_RELATIVE
|
|
|
|
# elf-relr-relocs2.s
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS32
|
|
Data: ELFDATA2LSB
|
|
Type: ET_DYN
|
|
Machine: EM_386
|
|
Entry: 0x00001000
|
|
Sections:
|
|
- Name: .relr.dyn
|
|
Type: SHT_RELR
|
|
Flags: [ SHF_ALLOC ]
|
|
Address: 0x000001C8
|
|
Link: .symtab
|
|
AddressAlign: 0x00000001
|
|
Content: 600D0100030100000000020001050F0009004050
|
|
...
|