2016-06-07 17:31:52 +08:00
|
|
|
// REQUIRES: arm
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/relocation-copy-arm.s -o %t2.o
|
2018-05-16 01:02:35 +08:00
|
|
|
// RUN: ld.lld -shared %t2.o -soname fixed-length-string.so -o %t2.so
|
2017-10-06 17:37:44 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t3
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S -r --expand-relocs --symbols %t3 | FileCheck %s
|
2019-07-22 19:37:03 +08:00
|
|
|
// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi --no-show-raw-insn %t3 | FileCheck -check-prefix=CODE %s
|
2016-06-07 17:31:52 +08:00
|
|
|
// RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi -section=.rodata %t3 | FileCheck -check-prefix=RODATA %s
|
|
|
|
|
|
|
|
// Copy relocations R_ARM_COPY are required for y and z
|
|
|
|
.syntax unified
|
|
|
|
.text
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
movw r2,:lower16: y
|
|
|
|
movt r2,:upper16: y
|
|
|
|
ldr r3,[pc,#4]
|
|
|
|
ldr r3,[r3,#0]
|
|
|
|
.rodata
|
|
|
|
.word z
|
|
|
|
|
|
|
|
// CHECK: Name: .bss
|
|
|
|
// CHECK-NEXT: Type: SHT_NOBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: 0x13000
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: 8
|
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment: 16
|
|
|
|
|
|
|
|
// CHECK: Relocations [
|
2018-06-27 06:13:32 +08:00
|
|
|
// CHECK-NEXT: Section {{.*}} .rel.dyn {
|
2016-06-07 17:31:52 +08:00
|
|
|
// CHECK-NEXT: Relocation {
|
|
|
|
// CHECK-NEXT: Offset: 0x13000
|
|
|
|
// CHECK-NEXT: Type: R_ARM_COPY
|
|
|
|
// CHECK-NEXT: Symbol: y
|
|
|
|
// CHECK-NEXT: Addend: 0x0
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Relocation {
|
|
|
|
// CHECK-NEXT: Offset: 0x13004
|
|
|
|
// CHECK-NEXT: Type: R_ARM_COPY
|
|
|
|
// CHECK-NEXT: Symbol: z
|
|
|
|
// CHECK-NEXT: Addend: 0x0
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
|
|
|
// CHECK: Symbols [
|
|
|
|
// CHECK: Name: y
|
|
|
|
// CHECK-NEXT: Value: 0x13000
|
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Object
|
|
|
|
// CHECK-NEXT: Other:
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
// CHECK: Name: z
|
|
|
|
// CHECK-NEXT: Value: 0x13004
|
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Object
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
|
|
|
|
// CODE: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CODE-EMPTY:
|
2016-06-07 17:31:52 +08:00
|
|
|
// CODE-NEXT: _start:
|
|
|
|
// S(y) = 0x13000, A = 0
|
|
|
|
// (S + A) & 0x0000ffff = 0x3000 = #12288
|
2019-07-22 19:37:03 +08:00
|
|
|
// CODE-NEXT: 11000: movw r2, #12288
|
2016-06-07 17:31:52 +08:00
|
|
|
// S(y) = 0x13000, A = 0
|
|
|
|
// ((S + A) & 0xffff0000) >> 16 = 0x1
|
2019-07-22 19:37:03 +08:00
|
|
|
// CODE-NEXT: 11004: movt r2, #1
|
|
|
|
// CODE-NEXT: 11008: ldr r3, [pc, #4]
|
|
|
|
// CODE-NEXT: 1100c: ldr r3, [r3]
|
2016-06-07 17:31:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
// RODATA: Contents of section .rodata:
|
|
|
|
// S(z) = 0x13004
|
[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
|
|
|
// RODATA-NEXT: 101b0 04300100
|