summaryrefslogtreecommitdiffstats
path: root/lld/test/ELF/avoid-empty-program-headers.s
Commit message (Collapse)AuthorAgeFilesLines
* [ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_X86_64Fangrui Song2019-09-161-6/+6
| | | | | | | | Port the D64906 technique to EM_X86_64. Differential Revision: https://reviews.llvm.org/D67482 llvm-svn: 371958
* [ELF] Add -z separate-code and pad the last page of last PF_X PT_LOAD with ↵Fangrui Song2019-08-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. https://github.com/richfelker/musl-cross-make/commit/d969dea983a2cc54a1e0308a0cdeb6c3307e4bfa 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
* [test] Change llvm-readobj -long-option to --long-option or well-known short ↵Fangrui Song2019-05-011-1/+1
| | | | | | | | | | | | options. NFC Also change some options that have different semantics (cause confusion) in llvm-readelf mode: -s => -S -t => --symbols -sd => --section-data llvm-svn: 359651
* [ELF] Set p_memsz to p_filesz when aligning the last segment to page boundaryPetr Hosek2017-09-011-1/+1
| | | | | | | | Having p_filesz different from p_memsz is confusing some tools. Differential Revision: https://reviews.llvm.org/D37369 llvm-svn: 312384
* [ELF] When the code segment is the last, align it to the page boundaryPetr Hosek2017-08-021-2/+2
| | | | | | | | | | | When the data segment is the last segment, it is correct to leave it unaligned. However, when the code segment is the last segment, it should be aligned to the page boundary to avoid loading the non-segment parts of the ELF file at the end of the file. Differential Revision: https://reviews.llvm.org/D33630 llvm-svn: 309829
* lld: Default image base address to 0x200000 on x86-64Ed Maste2016-11-231-8/+8
| | | | | | | | | Align to the large page size (known as a superpage or huge page). FreeBSD automatically promotes large, superpage-aligned allocations. Differential Revision: https://reviews.llvm.org/D27042 llvm-svn: 287782
* Don't include NOBITS TLS in PT_LOAD.Rafael Espindola2016-02-101-0/+78
They don't count for the memory or file size, so this is mostly just a simplification. The only noticeable difference should be fewer empty program headers. llvm-svn: 260465
OpenPOWER on IntegriCloud