forked from OSchip/llvm-project
[ELF] Add -z separate-code and pad the last page of last PF_X PT_LOAD with traps only if -z separate-code is specified
This patch
1) adds -z separate-code and -z noseparate-code (default).
2) changes the condition that the last page of last PF_X PT_LOAD is
padded with trap instructions.
Current condition (after D33630): if there is no `SECTIONS` commands.
After this change: if -z separate-code is specified.
-z separate-code was introduced to ld.bfd in 2018, to place the text
segment in its own pages. There is no overlap in pages between an
executable segment and a non-executable segment:
1) RX cannot load initial contents from R or RW(or non-SHF_ALLOC).
2) R and RW(or non-SHF_ALLOC) cannot load initial contents from RX.
lld's current status:
- Between R and RX: in `Writer<ELFT>::fixSectionAlignments()`, the start of a
segment is always aligned to maxPageSize, so the initial contents loaded by R
and RX do not overlap. I plan to allow overlaps in D64906 if -z noseparate-code
is in effect.
- Between RX and RW(or non-SHF_ALLOC if RW doesn't exist):
we currently unconditionally pad the last page to commonPageSize
(defaults to 4096 on all targets we support).
This patch will make it effective only if -z separate-code is specified.
-z separate-code is a dubious feature that intends to reduce the number
of ROP gadgets (which is actually ineffective because attackers can find
plenty of gadgets in the text segment, no need to find gadgets in
non-code regions).
With the overlapping PT_LOAD technique D64906, -z noseparate-code
removes two more alignments at segment boundaries than -z separate-code.
This saves at most defaultCommonPageSize*2 bytes, which are significant
on targets with large defaultCommonPageSize (AArch64/MIPS/PPC: 65536).
Issues/feedback on alignment at segment boundaries to help understand
the implication:
* binutils PR24490 (the situation on ld.bfd is worse because they have
two R-- on both sides of R-E so more alignments.)
* In binutils, the 2018-02-27 commit "ld: Add --enable-separate-code" made -z separate-code the default on Linux.
d969dea983
In musl-cross-make, binutils is configured with --disable-separate-code
to address size regressions caused by -z separate-code. (lld actually has the same
issue, which I plan to fix in a future patch. The ld.bfd x86 status is
worse because they default to max-page-size=0x200000).
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237676 people want
smaller code size. This patch will remove one alignment boundary.
* Stef O'Rear: I'm opposed to any kind of page alignment at the
text/rodata line (having a partial page of text aliased as rodata and
vice versa has no demonstrable harm, and I actually care about small
systems).
So, make -z noseparate-code the default.
Reviewed By: ruiu
Differential Revision: https://reviews.llvm.org/D64903
llvm-svn: 367537
This commit is contained in:
parent
07ceadda25
commit
5391f158c2
|
@ -210,6 +210,7 @@ struct Configuration {
|
|||
bool zOrigin;
|
||||
bool zRelro;
|
||||
bool zRodynamic;
|
||||
bool zSeparateCode;
|
||||
bool zText;
|
||||
bool zRetpolineplt;
|
||||
bool zWxneeded;
|
||||
|
|
|
@ -378,9 +378,10 @@ static bool isKnownZFlag(StringRef s) {
|
|||
s == "execstack" || s == "global" || s == "hazardplt" ||
|
||||
s == "ifunc-noplt" || s == "initfirst" || s == "interpose" ||
|
||||
s == "keep-text-section-prefix" || s == "lazy" || s == "muldefs" ||
|
||||
s == "nocombreloc" || s == "nocopyreloc" || s == "nodefaultlib" ||
|
||||
s == "nodelete" || s == "nodlopen" || s == "noexecstack" ||
|
||||
s == "nokeep-text-section-prefix" || s == "norelro" || s == "notext" ||
|
||||
s == "separate-code" || s == "nocombreloc" || s == "nocopyreloc" ||
|
||||
s == "nodefaultlib" || s == "nodelete" || s == "nodlopen" ||
|
||||
s == "noexecstack" || s == "nokeep-text-section-prefix" ||
|
||||
s == "norelro" || s == "noseparate-code" || s == "notext" ||
|
||||
s == "now" || s == "origin" || s == "relro" || s == "retpolineplt" ||
|
||||
s == "rodynamic" || s == "text" || s == "wxneeded" ||
|
||||
s.startswith("common-page-size") || s.startswith("max-page-size=") ||
|
||||
|
@ -935,6 +936,7 @@ static void readConfigs(opt::InputArgList &args) {
|
|||
config->zRelro = getZFlag(args, "relro", "norelro", true);
|
||||
config->zRetpolineplt = hasZOption(args, "retpolineplt");
|
||||
config->zRodynamic = hasZOption(args, "rodynamic");
|
||||
config->zSeparateCode = getZFlag(args, "separate-code", "noseparate-code", false);
|
||||
config->zStackSize = args::getZOptionValue(args, OPT_z, "stack-size", 0);
|
||||
config->zText = getZFlag(args, "text", "notext", true);
|
||||
config->zWxneeded = hasZOption(args, "wxneeded");
|
||||
|
|
|
@ -2289,13 +2289,11 @@ template <class ELFT> void Writer<ELFT>::assignFileOffsets() {
|
|||
|
||||
for (OutputSection *sec : outputSections) {
|
||||
off = setFileOffset(sec, off);
|
||||
if (script->hasSectionsCommand)
|
||||
continue;
|
||||
|
||||
// If this is a last section of the last executable segment and that
|
||||
// segment is the last loadable segment, align the offset of the
|
||||
// following section to avoid loading non-segments parts of the file.
|
||||
if (lastRX && lastRX->lastSec == sec)
|
||||
if (config->zSeparateCode && lastRX && lastRX->lastSec == sec)
|
||||
off = alignTo(off, config->commonPageSize);
|
||||
}
|
||||
|
||||
|
@ -2568,7 +2566,7 @@ static void fillTrap(uint8_t *i, uint8_t *end) {
|
|||
// We'll leave other pages in segments as-is because the rest will be
|
||||
// overwritten by output sections.
|
||||
template <class ELFT> void Writer<ELFT>::writeTrapInstr() {
|
||||
if (script->hasSectionsCommand)
|
||||
if (!config->zSeparateCode)
|
||||
return;
|
||||
|
||||
for (Partition &part : partitions) {
|
||||
|
|
|
@ -42,8 +42,8 @@ _start:
|
|||
// CHECK-NEXT: Offset: 0x1000
|
||||
// CHECK-NEXT: VirtualAddress: 0x201000
|
||||
// CHECK-NEXT: PhysicalAddress: 0x201000
|
||||
// CHECK-NEXT: FileSize: 4096
|
||||
// CHECK-NEXT: MemSize: 4096
|
||||
// CHECK-NEXT: FileSize: 1
|
||||
// CHECK-NEXT: MemSize: 1
|
||||
// CHECK-NEXT: Flags [ (0x5)
|
||||
// CHECK-NEXT: PF_R (0x4)
|
||||
// CHECK-NEXT: PF_X (0x1)
|
||||
|
@ -52,7 +52,7 @@ _start:
|
|||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ProgramHeader {
|
||||
// CHECK-NEXT: Type: PT_TLS (0x7)
|
||||
// CHECK-NEXT: Offset: 0x2000
|
||||
// CHECK-NEXT: Offset: 0x1001
|
||||
// CHECK-NEXT: VirtualAddress: 0x201001
|
||||
// CHECK-NEXT: PhysicalAddress: 0x201001
|
||||
// CHECK-NEXT: FileSize: 0
|
||||
|
|
|
@ -26,7 +26,7 @@ _start:
|
|||
# CHECK-NEXT: Version: 1
|
||||
# CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]]
|
||||
# CHECK-NEXT: ProgramHeaderOffset: 0x40
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x11088
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x10098
|
||||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: HeaderSize: 64
|
||||
|
@ -76,7 +76,7 @@ _start:
|
|||
# CHECK-NEXT: SHF_STRINGS (0x20)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x11000
|
||||
# CHECK-NEXT: Offset: 0x1000C
|
||||
# CHECK-NEXT: Size: 8
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -90,7 +90,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x11008
|
||||
# CHECK-NEXT: Offset: 0x10018
|
||||
# CHECK-NEXT: Size: 72
|
||||
# CHECK-NEXT: Link: 5
|
||||
# CHECK-NEXT: Info: 2
|
||||
|
@ -104,7 +104,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x11050
|
||||
# CHECK-NEXT: Offset: 0x10060
|
||||
# CHECK-NEXT: Size: 42
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -118,7 +118,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x1107A
|
||||
# CHECK-NEXT: Offset: 0x1008A
|
||||
# CHECK-NEXT: Size: 13
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -185,8 +185,8 @@ _start:
|
|||
# CHECK-NEXT: Offset: 0x1000
|
||||
# CHECK-NEXT: VirtualAddress: 0x210000
|
||||
# CHECK-NEXT: PhysicalAddress: 0x210000
|
||||
# CHECK-NEXT: FileSize: 4096
|
||||
# CHECK-NEXT: MemSize: 4096
|
||||
# CHECK-NEXT: FileSize: 12
|
||||
# CHECK-NEXT: MemSize: 12
|
||||
# CHECK-NEXT: Flags [ (0x5)
|
||||
# CHECK-NEXT: PF_R (0x4)
|
||||
# CHECK-NEXT: PF_X (0x1)
|
||||
|
|
|
@ -25,7 +25,7 @@ _start:
|
|||
# CHECK-NEXT: Version: 1
|
||||
# CHECK-NEXT: Entry: 0x401000
|
||||
# CHECK-NEXT: ProgramHeaderOffset: 0x34
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x205C
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x1068
|
||||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: HeaderSize: 52
|
||||
|
@ -75,7 +75,7 @@ _start:
|
|||
# CHECK-NEXT: SHF_STRINGS (0x20)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2000
|
||||
# CHECK-NEXT: Offset: 0x100C
|
||||
# CHECK-NEXT: Size: 8
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -89,7 +89,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2008
|
||||
# CHECK-NEXT: Offset: 0x1014
|
||||
# CHECK-NEXT: Size: 32
|
||||
# CHECK-NEXT: Link: 5
|
||||
# CHECK-NEXT: Info: 1
|
||||
|
@ -103,7 +103,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2028
|
||||
# CHECK-NEXT: Offset: 0x1034
|
||||
# CHECK-NEXT: Size: 42
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -117,7 +117,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2052
|
||||
# CHECK-NEXT: Offset: 0x105E
|
||||
# CHECK-NEXT: Size: 8
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -155,8 +155,8 @@ _start:
|
|||
# CHECK-NEXT: Offset: 0x1000
|
||||
# CHECK-NEXT: VirtualAddress: 0x401000
|
||||
# CHECK-NEXT: PhysicalAddress: 0x401000
|
||||
# CHECK-NEXT: FileSize: 4096
|
||||
# CHECK-NEXT: MemSize: 4096
|
||||
# CHECK-NEXT: FileSize: 12
|
||||
# CHECK-NEXT: MemSize: 12
|
||||
# CHECK-NEXT: Flags [ (0x5)
|
||||
# CHECK-NEXT: PF_R (0x4)
|
||||
# CHECK-NEXT: PF_X (0x1)
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// CHECK-NEXT: Version: 1
|
||||
// CHECK-NEXT: Entry: 0x10010000
|
||||
// CHECK-NEXT: ProgramHeaderOffset: 0x34
|
||||
// CHECK-NEXT: SectionHeaderOffset: 0x11044
|
||||
// CHECK-NEXT: SectionHeaderOffset: 0x10050
|
||||
// CHECK-NEXT: Flags [ (0x0)
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: HeaderSize: 52
|
||||
|
@ -83,7 +83,7 @@
|
|||
// CHECK-NEXT: SHF_STRINGS (0x20)
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x11000
|
||||
// CHECK-NEXT: Offset: 0x1000C
|
||||
// CHECK-NEXT: Size: 8
|
||||
// CHECK-NEXT: Link: 0
|
||||
// CHECK-NEXT: Info: 0
|
||||
|
@ -97,7 +97,7 @@
|
|||
// CHECK-NEXT: Flags [ (0x0)
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x11008
|
||||
// CHECK-NEXT: Offset: 0x10014
|
||||
// CHECK-NEXT: Size: 16
|
||||
// CHECK-NEXT: Link: 5
|
||||
// CHECK-NEXT: Info: 1
|
||||
|
@ -114,7 +114,7 @@
|
|||
// CHECK-NEXT: Flags [ (0x0)
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x11018
|
||||
// CHECK-NEXT: Offset: 0x10024
|
||||
// CHECK-NEXT: Size: 42
|
||||
// CHECK-NEXT: Link: 0
|
||||
// CHECK-NEXT: Info: 0
|
||||
|
@ -128,7 +128,7 @@
|
|||
// CHECK-NEXT: Flags [ (0x0)
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x11042
|
||||
// CHECK-NEXT: Offset: 0x1004E
|
||||
// CHECK-NEXT: Size: 1
|
||||
// CHECK-NEXT: Link: 0
|
||||
// CHECK-NEXT: Info: 0
|
||||
|
@ -169,8 +169,8 @@
|
|||
// CHECK-NEXT: Offset: 0x1000
|
||||
// CHECK-NEXT: VirtualAddress: 0x10010000
|
||||
// CHECK-NEXT: PhysicalAddress: 0x10010000
|
||||
// CHECK-NEXT: FileSize: 4096
|
||||
// CHECK-NEXT: MemSize: 4096
|
||||
// CHECK-NEXT: FileSize: 12
|
||||
// CHECK-NEXT: MemSize: 12
|
||||
// CHECK-NEXT: Flags [ (0x5)
|
||||
// CHECK-NEXT: PF_R (0x4)
|
||||
// CHECK-NEXT: PF_X (0x1)
|
||||
|
|
|
@ -26,7 +26,7 @@ _start:
|
|||
# CHECK-NEXT: Version: 1
|
||||
# CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]]
|
||||
# CHECK-NEXT: ProgramHeaderOffset: 0x40
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x102070
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x100080
|
||||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: HeaderSize: 64
|
||||
|
@ -76,7 +76,7 @@ _start:
|
|||
# CHECK-NEXT: SHF_STRINGS (0x20)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x102000
|
||||
# CHECK-NEXT: Offset: 0x10000C
|
||||
# CHECK-NEXT: Size: 8
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -90,7 +90,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x102008
|
||||
# CHECK-NEXT: Offset: 0x100018
|
||||
# CHECK-NEXT: Size: 48
|
||||
# CHECK-NEXT: Link: 5
|
||||
# CHECK-NEXT: Info: 1
|
||||
|
@ -104,7 +104,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x102038
|
||||
# CHECK-NEXT: Offset: 0x100048
|
||||
# CHECK-NEXT: Size: 42
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -118,7 +118,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x102062
|
||||
# CHECK-NEXT: Offset: 0x100072
|
||||
# CHECK-NEXT: Size: 8
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -176,8 +176,8 @@ _start:
|
|||
# CHECK-NEXT: Offset: 0x100000
|
||||
# CHECK-NEXT: VirtualAddress: 0x200000
|
||||
# CHECK-NEXT: PhysicalAddress: 0x200000
|
||||
# CHECK-NEXT: FileSize: 8192
|
||||
# CHECK-NEXT: MemSize: 8192
|
||||
# CHECK-NEXT: FileSize: 12
|
||||
# CHECK-NEXT: MemSize: 12
|
||||
# CHECK-NEXT: Flags [ (0x5)
|
||||
# CHECK-NEXT: PF_R (0x4)
|
||||
# CHECK-NEXT: PF_X (0x1)
|
||||
|
|
|
@ -28,7 +28,7 @@ _start:
|
|||
# CHECK-NEXT: Version: 1
|
||||
# CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]]
|
||||
# CHECK-NEXT: ProgramHeaderOffset: 0x40
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x2070
|
||||
# CHECK-NEXT: SectionHeaderOffset: 0x1080
|
||||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: HeaderSize: 64
|
||||
|
@ -78,7 +78,7 @@ _start:
|
|||
# CHECK-NEXT: SHF_STRINGS (0x20)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2000
|
||||
# CHECK-NEXT: Offset: 0x1010
|
||||
# CHECK-NEXT: Size: 8
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -92,7 +92,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2008
|
||||
# CHECK-NEXT: Offset: 0x1018
|
||||
# CHECK-NEXT: Size: 48
|
||||
# CHECK-NEXT: Link: 5
|
||||
# CHECK-NEXT: Info: 1
|
||||
|
@ -106,7 +106,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2038
|
||||
# CHECK-NEXT: Offset: 0x1048
|
||||
# CHECK-NEXT: Size: 42
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -120,7 +120,7 @@ _start:
|
|||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset: 0x2062
|
||||
# CHECK-NEXT: Offset: 0x1072
|
||||
# CHECK-NEXT: Size: 8
|
||||
# CHECK-NEXT: Link: 0
|
||||
# CHECK-NEXT: Info: 0
|
||||
|
@ -178,8 +178,8 @@ _start:
|
|||
# CHECK-NEXT: Offset: 0x1000
|
||||
# CHECK-NEXT: VirtualAddress: 0x201000
|
||||
# CHECK-NEXT: PhysicalAddress: 0x201000
|
||||
# CHECK-NEXT: FileSize: 4096
|
||||
# CHECK-NEXT: MemSize: 4096
|
||||
# CHECK-NEXT: FileSize: 16
|
||||
# CHECK-NEXT: MemSize: 16
|
||||
# CHECK-NEXT: Flags [ (0x5)
|
||||
# CHECK-NEXT: PF_R (0x4)
|
||||
# CHECK-NEXT: PF_X (0x1)
|
||||
|
|
|
@ -65,15 +65,15 @@ _start:
|
|||
# DEFAULT: Contents of section .note.test:
|
||||
# DEFAULT: Contents of section .note.gnu.build-id:
|
||||
# DEFAULT-NEXT: 04000000 08000000 03000000 474e5500 ............GNU.
|
||||
# DEFAULT-NEXT: 95849665 2621c734
|
||||
# DEFAULT-NEXT: 605e19a6 30469e00
|
||||
|
||||
# MD5: Contents of section .note.gnu.build-id:
|
||||
# MD5-NEXT: 04000000 10000000 03000000 474e5500 ............GNU.
|
||||
# MD5-NEXT: 1882c01f 71698eed 229b3994 eb554c80
|
||||
# MD5-NEXT: adbf65c5 42b4a428 184fd7c9 099cdc29
|
||||
|
||||
# SHA1: Contents of section .note.gnu.build-id:
|
||||
# SHA1-NEXT: 04000000 14000000 03000000 474e5500 ............GNU.
|
||||
# SHA1-NEXT: 96820adf d90d5470 0a0c32ff a88c4017
|
||||
# SHA1-NEXT: fe148fd4 1add2878 6b298b61 5880148b
|
||||
|
||||
# UUID: Contents of section .note.gnu.build-id:
|
||||
# UUID-NEXT: 04000000 10000000 03000000 474e5500 ............GNU.
|
||||
|
|
|
@ -54,7 +54,7 @@ _start:
|
|||
# CHECK-MAX-NEXT: SHF_STRINGS (0x20)
|
||||
# CHECK-MAX-NEXT: ]
|
||||
# CHECK-MAX-NEXT: Address: 0x0
|
||||
# CHECK-MAX-NEXT: Offset: 0x11000
|
||||
# CHECK-MAX-NEXT: Offset: 0x10001
|
||||
# CHECK-MAX-NEXT: Size: 8
|
||||
# CHECK-MAX-NEXT: Link: 0
|
||||
# CHECK-MAX-NEXT: Info: 0
|
||||
|
@ -91,8 +91,8 @@ _start:
|
|||
# CHECK-MAX-NEXT: Offset: 0x10000
|
||||
# CHECK-MAX-NEXT: VirtualAddress: 0x210000
|
||||
# CHECK-MAX-NEXT: PhysicalAddress: 0x210000
|
||||
# CHECK-MAX-NEXT: FileSize: 4096
|
||||
# CHECK-MAX-NEXT: MemSize: 4096
|
||||
# CHECK-MAX-NEXT: FileSize: 1
|
||||
# CHECK-MAX-NEXT: MemSize: 1
|
||||
# CHECK-MAX-NEXT: Flags [ (0x5)
|
||||
# CHECK-MAX-NEXT: PF_R (0x4)
|
||||
# CHECK-MAX-NEXT: PF_X (0x1)
|
||||
|
@ -164,7 +164,7 @@ _start:
|
|||
# CHECK-COMMON-NEXT: SHF_STRINGS (0x20)
|
||||
# CHECK-COMMON-NEXT: ]
|
||||
# CHECK-COMMON-NEXT: Address: 0x0
|
||||
# CHECK-COMMON-NEXT: Offset: 0x20000
|
||||
# CHECK-COMMON-NEXT: Offset: 0x10001
|
||||
# CHECK-COMMON-NEXT: Size: 8
|
||||
# CHECK-COMMON-NEXT: Link: 0
|
||||
# CHECK-COMMON-NEXT: Info: 0
|
||||
|
@ -201,8 +201,8 @@ _start:
|
|||
# CHECK-COMMON-NEXT: Offset: 0x10000
|
||||
# CHECK-COMMON-NEXT: VirtualAddress: 0x210000
|
||||
# CHECK-COMMON-NEXT: PhysicalAddress: 0x210000
|
||||
# CHECK-COMMON-NEXT: FileSize: 65536
|
||||
# CHECK-COMMON-NEXT: MemSize: 65536
|
||||
# CHECK-COMMON-NEXT: FileSize: 1
|
||||
# CHECK-COMMON-NEXT: MemSize: 1
|
||||
# CHECK-COMMON-NEXT: Flags [ (0x5)
|
||||
# CHECK-COMMON-NEXT: PF_R (0x4)
|
||||
# CHECK-COMMON-NEXT: PF_X (0x1)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# REQUIRES: ppc
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=powerpc64le-linux %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t.ppc64le
|
||||
# RUN: ld.lld %t.o -z separate-code -o %t.ppc64le
|
||||
# RUN: llvm-readobj -l %t.ppc64le | FileCheck %s
|
||||
# RUN: od -Ax -t x1 -N16 -j0x10ff0 %t.ppc64le | FileCheck %s -check-prefix=LE
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=powerpc64-linux %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t.ppc64
|
||||
# RUN: ld.lld %t.o -z separate-code -o %t.ppc64
|
||||
# RUN: llvm-readobj -l %t.ppc64 | FileCheck %s
|
||||
# RUN: od -Ax -t x1 -N16 -j0x10ff0 %t.ppc64 | FileCheck %s -check-prefix=BE
|
||||
|
||||
|
|
|
@ -1,16 +1,27 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||
# RUN: ld.lld %t -o %t2
|
||||
# RUN: llvm-readobj -l %t2 | FileCheck %s
|
||||
# RUN: od -Ax -x -N16 -j0x1ff0 %t2 | FileCheck %s -check-prefix=FILL
|
||||
## -z noseparate-code is the default: text segment is not tail padded.
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD
|
||||
# RUN: ld.lld %t.o -z noseparate-code -o %t
|
||||
# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD
|
||||
|
||||
## -z separate-code pads the tail of text segment with traps.
|
||||
# RUN: ld.lld %t.o -z separate-code -o %t
|
||||
# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,PAD
|
||||
# RUN: od -Ax -x -N16 -j0x1ff0 %t | FileCheck %s --check-prefix=FILL
|
||||
|
||||
# RUN: ld.lld %t.o -z separate-code -z noseparate-code -o %t
|
||||
# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD
|
||||
|
||||
# CHECK: ProgramHeader {
|
||||
# CHECK: Type: PT_LOAD
|
||||
# CHECK: Offset: 0x1000
|
||||
# CHECK-NEXT: VirtualAddress:
|
||||
# CHECK-NEXT: PhysicalAddress:
|
||||
# CHECK-NEXT: FileSize: 4096
|
||||
# PAD-NEXT: FileSize: 4096
|
||||
# NOPAD-NEXT: FileSize: 1
|
||||
# CHECK-NEXT: MemSize:
|
||||
# CHECK-NEXT: Flags [
|
||||
# CHECK-NEXT: PF_R
|
||||
|
|
|
@ -47,8 +47,8 @@ _start:
|
|||
# CHECK-NEXT: Offset: 0x1000
|
||||
# CHECK-NEXT: VirtualAddress: 0x1001000
|
||||
# CHECK-NEXT: PhysicalAddress: 0x1001000
|
||||
# CHECK-NEXT: FileSize: 4096
|
||||
# CHECK-NEXT: MemSize: 4096
|
||||
# CHECK-NEXT: FileSize: 1
|
||||
# CHECK-NEXT: MemSize: 1
|
||||
# CHECK-NEXT: Flags [ (0x5)
|
||||
# CHECK-NEXT: PF_R (0x4)
|
||||
# CHECK-NEXT: PF_X (0x1)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; REQUIRES: msp430
|
||||
; RUN: llvm-mc -filetype=obj -triple=msp430-elf -o %t1.o %s
|
||||
; RUN: echo -e '.global _start\n _start: nop' | llvm-mc -filetype=obj -triple=msp430-elf -o %t2.o -
|
||||
; RUN: ld.lld -o %t.exe --Tdata=0x2000 --Ttext=0x8000 --defsym=_byte=0x21 %t2.o %t1.o
|
||||
; RUN: ld.lld -o %t.exe --Tdata=0x2000 --Ttext=0x8000 --defsym=_byte=0x21 -z separate-code %t2.o %t1.o
|
||||
; RUN: llvm-objdump -s -d %t.exe | FileCheck %s
|
||||
|
||||
;; Check handling of basic msp430 relocation types.
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o
|
||||
// RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t1.script
|
||||
// RUN: ld.lld -shared %t1.o --version-script %t1.script -o %t1.so -soname verneed1.so.0
|
||||
// RUN: ld.lld -shared %t1.o --version-script %t1.script -o %t1.so -soname verneed1.so.0 -z separate-code
|
||||
|
||||
// RUN: llvm-mc %s -o %t.o -filetype=obj --triple=x86_64-unknown-linux
|
||||
// RUN: echo "x1 { global: p0; }; x2 { global: p1; p1alias; };" > %t.script
|
||||
// RUN: ld.lld %t.o %t1.so --version-script %t.script -o %t --shared --gc-sections --eh-frame-hdr -soname main.so
|
||||
// RUN: ld.lld %t.o %t1.so --version-script %t.script -o %t --shared --gc-sections --eh-frame-hdr -soname main.so -z separate-code
|
||||
|
||||
// RUN: llvm-objcopy --extract-main-partition %t %t0
|
||||
// RUN: llvm-objcopy --extract-partition=part1 %t %t1
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
# CHECKEXE-NEXT: Version: 1
|
||||
# CHECKEXE-NEXT: Entry: 0x201000
|
||||
# CHECKEXE-NEXT: ProgramHeaderOffset: 0x40
|
||||
# CHECKEXE-NEXT: SectionHeaderOffset: 0x21A0
|
||||
# CHECKEXE-NEXT: SectionHeaderOffset: 0x11F8
|
||||
# CHECKEXE-NEXT: Flags [
|
||||
# CHECKEXE-NEXT: ]
|
||||
# CHECKEXE-NEXT: HeaderSize: 64
|
||||
|
|
Loading…
Reference in New Issue