2017-01-14 05:05:46 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file2.s -o %t2.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file3.s -o %t3.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file4.s -o %t4.o
|
2017-12-05 22:23:18 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file5.s -o %t5.o
|
|
|
|
// RUN: ld.lld -shared %t5.o -o %t5.so -soname dso
|
2017-01-14 05:05:46 +08:00
|
|
|
// RUN: rm -f %t4.a
|
|
|
|
// RUN: llvm-ar rc %t4.a %t4.o
|
2017-12-05 22:23:18 +08:00
|
|
|
// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so -o %t -M | FileCheck -strict-whitespace %s
|
|
|
|
// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so -o %t -print-map | FileCheck -strict-whitespace %s
|
|
|
|
// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so -o %t -Map=%t.map
|
2017-04-29 01:19:13 +08:00
|
|
|
// RUN: FileCheck -strict-whitespace %s < %t.map
|
2017-01-14 05:05:46 +08:00
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
2018-03-15 05:18:18 +08:00
|
|
|
.cfi_startproc
|
|
|
|
.cfi_endproc
|
2017-12-05 22:23:18 +08:00
|
|
|
.quad sharedFoo
|
|
|
|
.quad sharedBar
|
2018-02-17 04:05:58 +08:00
|
|
|
.byte 0xe8
|
|
|
|
.long sharedFunc1 - .
|
|
|
|
.byte 0xe8
|
|
|
|
.long sharedFunc2 - .
|
|
|
|
.byte 0xe8
|
|
|
|
.long baz - .
|
2017-01-14 05:05:46 +08:00
|
|
|
.global _Z1fi
|
|
|
|
_Z1fi:
|
|
|
|
.cfi_startproc
|
|
|
|
nop
|
2018-03-15 05:18:18 +08:00
|
|
|
.cfi_endproc
|
2017-01-14 05:05:46 +08:00
|
|
|
.weak bar
|
|
|
|
bar:
|
|
|
|
.long bar - .
|
|
|
|
.long zed - .
|
|
|
|
local:
|
2017-02-01 04:42:34 +08:00
|
|
|
.comm common,4,16
|
2017-08-12 01:47:12 +08:00
|
|
|
.global abs
|
|
|
|
abs = 0xAB5
|
|
|
|
labs = 0x1AB5
|
2017-01-14 05:05:46 +08:00
|
|
|
|
2018-04-06 01:20:18 +08:00
|
|
|
// CHECK: VMA LMA Size Align Out In Symbol
|
[ELF] Split RW PT_LOAD on the PT_GNU_RELRO boundary
Summary:
Based on Peter Collingbourne's suggestion in D56828.
Before D56828: PT_LOAD(.data PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .bss)
Old: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .data .bss)
New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro)) PT_LOAD(.data. .bss)
The new layout reflects the runtime memory mappings.
By having two PT_LOAD segments, we can utilize the NOBITS part of the
first PT_LOAD and save bytes for .bss.rel.ro.
.bss.rel.ro is currently small and only used by copy relocations of
symbols in read-only segments, but it can be used for other purposes in
the future, e.g. if a relro section's statically relocated data is all
zeros, we can move it to .bss.rel.ro.
Reviewers: espindola, ruiu, pcc
Reviewed By: ruiu
Subscribers: nemanjai, jvesely, nhaehnle, javed.absar, kbarton, emaste, arichardson, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58892
llvm-svn: 356226
2019-03-15 09:29:57 +08:00
|
|
|
// CHECK-NEXT: 200200 200200 78 8 .dynsym
|
|
|
|
// CHECK-NEXT: 200200 200200 78 8 <internal>:(.dynsym)
|
|
|
|
// CHECK-NEXT: 200278 200278 2c 8 .gnu.hash
|
|
|
|
// CHECK-NEXT: 200278 200278 2c 8 <internal>:(.gnu.hash)
|
|
|
|
// CHECK-NEXT: 2002a4 2002a4 30 4 .hash
|
|
|
|
// CHECK-NEXT: 2002a4 2002a4 30 4 <internal>:(.hash)
|
|
|
|
// CHECK-NEXT: 2002d4 2002d4 31 1 .dynstr
|
|
|
|
// CHECK-NEXT: 2002d4 2002d4 31 1 <internal>:(.dynstr)
|
|
|
|
// CHECK-NEXT: 200308 200308 30 8 .rela.dyn
|
|
|
|
// CHECK-NEXT: 200308 200308 30 8 <internal>:(.rela.dyn)
|
|
|
|
// CHECK-NEXT: 200338 200338 30 8 .rela.plt
|
|
|
|
// CHECK-NEXT: 200338 200338 30 8 <internal>:(.rela.plt)
|
|
|
|
// CHECK-NEXT: 200368 200368 64 8 .eh_frame
|
|
|
|
// CHECK-NEXT: 200368 200368 2c 1 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x0)
|
|
|
|
// CHECK-NEXT: 200398 200398 14 1 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x2c)
|
|
|
|
// CHECK-NEXT: 2003b0 2003b0 18 1 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.eh_frame+0x18)
|
2018-04-06 01:20:18 +08:00
|
|
|
// CHECK-NEXT: 201000 201000 2d 4 .text
|
|
|
|
// CHECK-NEXT: 201000 201000 28 4 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text)
|
|
|
|
// CHECK-NEXT: 201000 201000 0 1 _start
|
|
|
|
// CHECK-NEXT: 20101f 20101f 0 1 f(int)
|
|
|
|
// CHECK-NEXT: 201028 201028 0 1 local
|
|
|
|
// CHECK-NEXT: 201028 201028 2 4 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text)
|
|
|
|
// CHECK-NEXT: 201028 201028 0 1 foo
|
|
|
|
// CHECK-NEXT: 201029 201029 0 1 bar
|
|
|
|
// CHECK-NEXT: 20102a 20102a 0 1 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text.zed)
|
|
|
|
// CHECK-NEXT: 20102a 20102a 0 1 zed
|
|
|
|
// CHECK-NEXT: 20102c 20102c 0 4 {{.*}}{{/|\\}}map-file.s.tmp3.o:(.text)
|
|
|
|
// CHECK-NEXT: 20102c 20102c 0 1 bah
|
|
|
|
// CHECK-NEXT: 20102c 20102c 1 4 {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o):(.text)
|
|
|
|
// CHECK-NEXT: 20102c 20102c 0 1 baz
|
|
|
|
// CHECK-NEXT: 201030 201030 30 16 .plt
|
|
|
|
// CHECK-NEXT: 201030 201030 30 16 <internal>:(.plt)
|
2018-04-27 01:58:58 +08:00
|
|
|
// CHECK-NEXT: 201040 201040 0 1 sharedFunc1
|
|
|
|
// CHECK-NEXT: 201050 201050 0 1 sharedFunc2
|
[ELF] Simplify RelRo, TLS, NOBITS section ranks and make RW PT_LOAD start with RelRo
Old: PT_LOAD(.data | PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .bss)
New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .data .bss)
The placement of | indicates page alignment caused by PT_GNU_RELRO. The
new layout has simpler rules and saves space for many cases.
Old size: roundup(.data) + roundup(.data.rel.ro)
New size: roundup(.data.rel.ro + .bss.rel.ro) + .data
Other advantages:
* At runtime the 3 memory mappings decrease to 2.
* start(PT_TLS) = start(PT_GNU_RELRO) = start(RW PT_LOAD). This
simplifies binary manipulation tools.
GNU strip before 2.31 discards PT_GNU_RELRO if its
address is not equal to the start of its associated PT_LOAD.
This has been fixed by https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f
But with this change, we will be compatible with GNU strip before 2.31
* Before, .got.plt (non-relro by default) was placed before .got (relro
by default), which made it impossible to have _GLOBAL_OFFSET_TABLE_
(start of .got.plt on x86-64) equal to the end of .got (R_GOT*_FROM_END)
(https://bugs.llvm.org/show_bug.cgi?id=36555). With the new ordering, we
can improve on this regard if we'd like to.
Reviewers: ruiu, espindola, pcc
Subscribers: emaste, arichardson, llvm-commits, joerg, jdoerfert
Differential Revision: https://reviews.llvm.org/D56828
llvm-svn: 356117
2019-03-14 11:47:45 +08:00
|
|
|
// CHECK-NEXT: 202000 202000 100 8 .dynamic
|
|
|
|
// CHECK-NEXT: 202000 202000 100 8 <internal>:(.dynamic)
|
|
|
|
// CHECK-NEXT: 203000 203000 28 8 .got.plt
|
|
|
|
// CHECK-NEXT: 203000 203000 28 8 <internal>:(.got.plt)
|
|
|
|
// CHECK-NEXT: 203030 203030 10 16 .bss
|
|
|
|
// CHECK-NEXT: 203030 203030 4 16 {{.*}}{{/|\\}}map-file.s.tmp1.o:(COMMON)
|
|
|
|
// CHECK-NEXT: 203030 203030 4 1 common
|
|
|
|
// CHECK-NEXT: 203034 203034 4 1 <internal>:(.bss)
|
|
|
|
// CHECK-NEXT: 203034 203034 4 1 sharedFoo
|
|
|
|
// CHECK-NEXT: 203038 203038 8 1 <internal>:(.bss)
|
|
|
|
// CHECK-NEXT: 203038 203038 8 1 sharedBar
|
2018-04-06 01:20:18 +08:00
|
|
|
// CHECK-NEXT: 0 0 8 1 .comment
|
|
|
|
// CHECK-NEXT: 0 0 8 1 <internal>:(.comment)
|
|
|
|
// CHECK-NEXT: 0 0 198 8 .symtab
|
|
|
|
// CHECK-NEXT: 0 0 198 8 <internal>:(.symtab)
|
|
|
|
// CHECK-NEXT: 0 0 84 1 .shstrtab
|
|
|
|
// CHECK-NEXT: 0 0 84 1 <internal>:(.shstrtab)
|
|
|
|
// CHECK-NEXT: 0 0 6d 1 .strtab
|
|
|
|
// CHECK-NEXT: 0 0 6d 1 <internal>:(.strtab)
|
2017-01-18 11:34:38 +08:00
|
|
|
|
2018-05-16 01:02:35 +08:00
|
|
|
|
2017-01-18 11:34:38 +08:00
|
|
|
// RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=FAIL %s
|
2017-04-04 17:42:24 +08:00
|
|
|
// FAIL: cannot open map file /
|