2016-03-30 20:40:38 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t.o
|
|
|
|
// RUN: ld.lld %t.o -o %t -shared
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S --section-data %t | FileCheck %s
|
2016-03-30 20:40:38 +08:00
|
|
|
|
|
|
|
// CHECK: Name: .mysec
|
|
|
|
// CHECK-NEXT: Type:
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_MERGE
|
|
|
|
// CHECK-NEXT: ]
|
[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: Address: 0x178
|
2016-03-30 20:40:38 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size:
|
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment:
|
|
|
|
// CHECK-NEXT: EntrySize:
|
|
|
|
// CHECK-NEXT: SectionData (
|
|
|
|
// CHECK-NEXT: 0000: 42000000 |
|
|
|
|
// CHECK-NEXT: )
|
|
|
|
|
|
|
|
|
2016-05-05 04:25:19 +08:00
|
|
|
// CHECK: Name: .data
|
2016-03-30 20:40:38 +08:00
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
2016-05-05 04:25:19 +08:00
|
|
|
// CHECK-NEXT: SHF_WRITE
|
2016-03-30 20:40:38 +08:00
|
|
|
// CHECK-NEXT: ]
|
2019-08-20 16:43:47 +08:00
|
|
|
// CHECK-NEXT: Address: 0x31D4
|
|
|
|
// CHECK-NEXT: Offset: 0x1D4
|
2016-03-30 20:40:38 +08:00
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Link: 0
|
|
|
|
// CHECK-NEXT: Info: 0
|
2016-05-05 04:25:19 +08:00
|
|
|
// CHECK-NEXT: AddressAlignment: 1
|
2016-03-30 20:40:38 +08:00
|
|
|
// CHECK-NEXT: EntrySize: 0
|
|
|
|
// CHECK-NEXT: SectionData (
|
[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: 0000: 78010000 |
|
2016-03-30 20:40:38 +08:00
|
|
|
// CHECK-NEXT: )
|
|
|
|
|
2018-06-27 06:13:32 +08:00
|
|
|
// The content of .data should be the address of .mysec.
|
2016-03-30 20:40:38 +08:00
|
|
|
|
2016-05-05 04:25:19 +08:00
|
|
|
.data
|
2016-03-30 20:40:38 +08:00
|
|
|
.long .mysec+4
|
|
|
|
|
|
|
|
.section .mysec,"aM",@progbits,4
|
|
|
|
.align 4
|
|
|
|
.long 0x42
|
|
|
|
.long 0x42
|