Commit Graph

13 Commits

Author SHA1 Message Date
Fangrui Song b159906a9a [test] Change llvm-readobj -long-option to --long-option or well-known short 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
2019-05-01 05:49:01 +00:00
Fangrui Song 1092fc9057 [ELF] Allow sh_entsize to be unrelated to sh_addralign and not a power of 2
Summary:
This implements Rui Ueyama's idea in PR39044.
I've checked that ld.bfd and gold do not have the power-of-2 requirement
and do not require sh_entsize to be a multiple of sh_align.

Now on the updated test merge-entsize.s, all the 3 linkers happily
create .rodata that is not 3-byte aligned.

This has a use case in Linux arch/x86/crypto/sha512-avx2-asm.S
It uses sh_entsize of 640, which is not a power of 2.
See https://github.com/ClangBuiltLinux/linux/issues/417

Reviewers: ruiu, espindola

Reviewed By: ruiu

Subscribers: nickdesaulniers, E5ten, emaste, arichardson, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59478

llvm-svn: 356428
2019-03-18 23:49:18 +00:00
Fangrui Song 3d87323a7e [ELF] Make non-writable non-executable PROGBITS sections closer to .text
This generalizes the old heuristic placing SHT_DYNSYM SHT_DYNSTR first in the readonly SHF_ALLOC segment.

Reviewers: espindola

Subscribers: emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D48406

llvm-svn: 335674
2018-06-26 22:13:32 +00:00
Han Shen b56030ee9e [lld] Mitigate relocation overflow [part 1 of 2].
This CL places .dynsym and .dynstr at the beginning of SHF_ALLOC
sections. We do this to mitigate the possibility that huge .dynsym and
.dynstr sections placed between ro-data and text sections cause
relocation overflow.

Differential Revision: https://reviews.llvm.org/D45788

llvm-svn: 332374
2018-05-15 17:02:35 +00:00
George Rimar 4c9ae67bb7 [ELF] - Revert of: r332038, r332054, r332060, r332061, r332062, r332063
This reverts "Mitigate relocation overflow [part 1 of 2]." and the following commits which
were trying to fix the bots.

At the moment of r332082, bots are still failing and we need to find the reason of test case breakages first of all.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/17042/steps/test/logs/stdio
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/29845/steps/test/logs/stdio

llvm-svn: 332085
2018-05-11 08:11:25 +00:00
Han Shen 6c0881c3cd Mitigate relocation overflow [part 1 of 2].
This CL is to mitigate R_X86_64_PC32 relocation overflow problems for huge binaries that has near 4G allocated sections.

By examining those binaries, there're 2 issues contributes to the problem:
1). huge ".dynsym" and ".dynstr" stands in the way between .rodata and .text
2). _init_array_start/end are placed at 0 if no ".init_array" presents, this causes .text relocation against them become more prone to overflow.

This CL addresses 1st problem (the 2nd will be addressed in another CL.) by assigning a smaller sortrank to .dynsym and .dynstr thus they no longer stand in between.

llvm-svn: 332038
2018-05-10 20:44:42 +00:00
Rui Ueyama 7b19c34550 Revert "ELF: Make .note.GNU-stack more compatible with traditional linkers."
This reverts commit r253797 because it was based on a misunderstanding
that lld wouldn't work on NetBSD without this change.

llvm-svn: 254003
2015-11-24 18:48:16 +00:00
George Rimar e3336c0be6 Reapply fixed r253967.
llvm-svn: 253971
2015-11-24 10:15:50 +00:00
George Rimar 11721ce810 Revert r253967 which broke buildbot.
llvm-svn: 253970
2015-11-24 10:04:22 +00:00
George Rimar 63a6ca9150 [ELF] Implements -z relro: create an ELF "PT_GNU_RELRO" segment header in the object.
Partial (-z relro) and full (-z relro, -z now) relro cases are implemented.

Partial relro:
The ELF sections are reordered so that the ELF internal data sections (.got, .dtors, etc.) precede the program's data sections (.data and .bss).
.got is readonly, .got.plt is still writeable.

Full relro:
Supports all the features of partial RELRO, .got.plt is also readonly.

Differential revision: http://reviews.llvm.org/D14218

llvm-svn: 253967
2015-11-24 09:44:28 +00:00
Rui Ueyama e79b09a616 ELF: Make .note.GNU-stack more compatible with traditional linkers.
With this patch, lld creates PT_GNU_STACK segments only when all input
files have .note.GNU-stack sections. This is in line with other linkers
with a minor difference (we don't care about .note.GNU-stack rwx bits as
you can always remove .note.GNU-stack sections instead of setting x bit.)

At least, NetBSD loader does not understand PT_GNU_STACK segments and
reject any executables that have the section. This patch makes lld
compatible with such operating systems.

llvm-svn: 253797
2015-11-21 22:19:32 +00:00
Rafael Espindola 9c8904fb38 Rename ld.lld2 to ld.lld since it is the default.
llvm-svn: 253437
2015-11-18 06:11:01 +00:00
Rafael Espindola 4b1285c55a Rename test/elf2 to test/ELF.
llvm-svn: 253313
2015-11-17 05:36:42 +00:00