| #
fdd31965 |
| 02-Jul-2024 |
Fangrui Song <i@maskray.me> |
[ELF] Make start/stop symbols retain associated discardable output sections
An empty output section specified in the `SECTIONS` command (e.g. `empty : { *(empty) }`) may be discarded. Due to phase o
[ELF] Make start/stop symbols retain associated discardable output sections
An empty output section specified in the `SECTIONS` command (e.g. `empty : { *(empty) }`) may be discarded. Due to phase ordering, we might define `__start_empty`/`__stop_empty` symbols with incorrect section indexes (usually benign, but could go out of bounds and cause `readelf -s` to print `BAD`).
``` finalizeSections addStartStopSymbols // __start_empty is defined // __start_empty is added to .symtab sortSections adjustOutputSections // `empty` is discarded writeSections // __start_empty is Defined with an invalid section index ```
Loaders use `st_value` members of the start/stop symbols and expect no "undefined symbol" linker error, but do not particularly care whether the symbols are defined or undefined. Let's retain the associated empty output section so that start/stop symbols will have correct section indexes.
The approach allows us to remove `LinkerScript::isDiscarded` (https://reviews.llvm.org/D114179). Also delete the `findSection(".text")` special case from https://reviews.llvm.org/D46200, which is unnecessary even before this patch (`elfHeader` would be fine even with very large executables).
Note: we should be careful not to unnecessarily retain .ARM.exidx, which would create an empty PT_ARM_EXIDX. ~40 tests would need to be updated.
---
An alternative is to discard the empty output section and keep the start/stop symbols undefined. This approach needs more code and requires `LinkerScript::isDiscarded` before we discard empty sections in ``adjustOutputSections`.
Pull Request: https://github.com/llvm/llvm-project/pull/96343
show more ...
|
|
Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1, llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4, llvmorg-12.0.0-rc3, llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1, llvmorg-11.0.1, llvmorg-11.0.1-rc2, llvmorg-11.0.1-rc1, llvmorg-11.0.0, llvmorg-11.0.0-rc6, llvmorg-11.0.0-rc5, llvmorg-11.0.0-rc4, llvmorg-11.0.0-rc3, llvmorg-11.0.0-rc2, llvmorg-11.0.0-rc1, llvmorg-12-init, llvmorg-10.0.1, llvmorg-10.0.1-rc4, llvmorg-10.0.1-rc3, llvmorg-10.0.1-rc2, llvmorg-10.0.1-rc1, llvmorg-10.0.0, llvmorg-10.0.0-rc6 |
|
| #
87de9a07 |
| 22-Mar-2020 |
Fangrui Song <maskray@google.com> |
[X86InstPrinter] Change printPCRelImm to print the target address in hexadecimal form
``` // llvm-objdump -d output (before) 400000: e8 0b 00 00 00 callq 11 400005: e8 0b 00 00 00 callq 11
// l
[X86InstPrinter] Change printPCRelImm to print the target address in hexadecimal form
``` // llvm-objdump -d output (before) 400000: e8 0b 00 00 00 callq 11 400005: e8 0b 00 00 00 callq 11
// llvm-objdump -d output (after) 400000: e8 0b 00 00 00 callq 0x400010 400005: e8 0b 00 00 00 callq 0x400015
// GNU objdump -d. The lack of 0x is not ideal because the result cannot be re-assembled 400000: e8 0b 00 00 00 callq 400010 400005: e8 0b 00 00 00 callq 400015 ```
In llvm-objdump, we pass the address of the next MCInst. Ideally we should just thread the address of the current address, unfortunately we cannot call X86MCCodeEmitter::encodeInstruction (X86MCCodeEmitter requires MCInstrInfo and MCContext) to get the length of the MCInst.
MCInstPrinter::printInst has other callers (e.g llvm-mc -filetype=asm, llvm-mca) which set Address to 0. They leave MCInstPrinter::PrintBranchImmAsAddress as false and this change is a no-op for them.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D76580
show more ...
|
|
Revision tags: llvmorg-10.0.0-rc5, llvmorg-10.0.0-rc4 |
|
| #
71e2ca6e |
| 05-Mar-2020 |
Fangrui Song <maskray@google.com> |
[llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:`
The new behavior matches GNU objdump. A pair of angle brackets makes tests slightly easier.
`.foo:` is not unique and thus cann
[llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:`
The new behavior matches GNU objdump. A pair of angle brackets makes tests slightly easier.
`.foo:` is not unique and thus cannot be used in a `CHECK-LABEL:` directive. Without `-LABEL`, the CHECK line can match the `Disassembly of section` line and causes the next `CHECK-NEXT:` to fail.
``` Disassembly of section .foo:
0000000000001634 .foo: ```
Bdragon: <> has metalinguistic connotation. it just "feels right"
Reviewed By: rupprecht
Differential Revision: https://reviews.llvm.org/D75713
show more ...
|
|
Revision tags: llvmorg-10.0.0-rc3, llvmorg-10.0.0-rc2, llvmorg-10.0.0-rc1, llvmorg-11-init, llvmorg-9.0.1, llvmorg-9.0.1-rc3, llvmorg-9.0.1-rc2, llvmorg-9.0.1-rc1, llvmorg-9.0.0, llvmorg-9.0.0-rc6 |
|
| #
d4306e90 |
| 16-Sep-2019 |
Fangrui Song <maskray@google.com> |
[ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_X86_64
Port the D64906 technique to EM_X86_64.
Differential Revision: https://reviews.llvm.org/D67482
llvm-svn: 371958
|
|
Revision tags: llvmorg-9.0.0-rc5, llvmorg-9.0.0-rc4 |
|
| #
0e79890d |
| 07-Sep-2019 |
Fangrui Song <maskray@google.com> |
[ELF][test] Improve tests
Add file-level comments Delete insignificant addresses to make them more tolerant to layout changes Simplify test output
Delete weak-undef-val.s - covered by relocation-un
[ELF][test] Improve tests
Add file-level comments Delete insignificant addresses to make them more tolerant to layout changes Simplify test output
Delete weak-undef-val.s - covered by relocation-undefined-weak.s Delete weak-undef-export.s - covered by additional test added to weak-undef.s Delete version-undef-sym.s - covered by undefined-versioned-symbol.s => version-symbol-undef.s Delete symbol-ordering-file2.s - covered by symbol-ordering-file.s Delete gotpcrelx.s - covered by gotpc-relax-und-dso.s => x86-64-gotpc-relax-und-dso.s
llvm-svn: 371299
show more ...
|
|
Revision tags: llvmorg-9.0.0-rc3, llvmorg-9.0.0-rc2, llvmorg-9.0.0-rc1, llvmorg-10-init, llvmorg-8.0.1, llvmorg-8.0.1-rc4, llvmorg-8.0.1-rc3, llvmorg-8.0.1-rc2, llvmorg-8.0.1-rc1 |
|
| #
5387c2cd |
| 01-May-2019 |
Fangrui Song <maskray@google.com> |
[llvm-objdump] Print newlines before and after "Disassembly of section ...:"
This improves readability and the behavior is consistent with GNU objdump.
The new test test/tools/llvm-objdump/X86/disa
[llvm-objdump] Print newlines before and after "Disassembly of section ...:"
This improves readability and the behavior is consistent with GNU objdump.
The new test test/tools/llvm-objdump/X86/disassemble-section-name.s checks we print newlines before and after "Disassembly of section ...:"
Differential Revision: https://reviews.llvm.org/D61127
llvm-svn: 359668
show more ...
|
|
Revision tags: llvmorg-8.0.0, llvmorg-8.0.0-rc5, llvmorg-8.0.0-rc4, llvmorg-8.0.0-rc3, llvmorg-7.1.0, llvmorg-7.1.0-rc1, llvmorg-8.0.0-rc2, llvmorg-8.0.0-rc1, llvmorg-7.0.1, llvmorg-7.0.1-rc3, llvmorg-7.0.1-rc2, llvmorg-7.0.1-rc1, llvmorg-7.0.0, llvmorg-7.0.0-rc3, llvmorg-7.0.0-rc2, llvmorg-7.0.0-rc1 |
|
| #
b6772b86 |
| 26-Jun-2018 |
Fangrui Song <maskray@google.com> |
[ELF] Move `// REQUIRES:` line to the top
llvm-svn: 335676
|
|
Revision tags: llvmorg-6.0.1, llvmorg-6.0.1-rc3, llvmorg-6.0.1-rc2 |
|
| #
3aede928 |
| 18-May-2018 |
Han Shen <shenhan@google.com> |
Mitigate relocation overflow [part 2 of 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 sets "
Mitigate relocation overflow [part 2 of 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 sets ".init_array" address to that of ".text" to mitigate the situation.
Review: https://reviews.llvm.org/D46200 llvm-svn: 332688
show more ...
|
|
Revision tags: llvmorg-6.0.1-rc1, llvmorg-5.0.2, llvmorg-5.0.2-rc2, llvmorg-5.0.2-rc1, llvmorg-6.0.0, llvmorg-6.0.0-rc3, llvmorg-6.0.0-rc2, llvmorg-6.0.0-rc1, llvmorg-5.0.1, llvmorg-5.0.1-rc3, llvmorg-5.0.1-rc2, llvmorg-5.0.1-rc1, llvmorg-5.0.0, llvmorg-5.0.0-rc5, llvmorg-5.0.0-rc4, llvmorg-5.0.0-rc3, llvmorg-5.0.0-rc2, llvmorg-5.0.0-rc1, llvmorg-4.0.1, llvmorg-4.0.1-rc3, llvmorg-4.0.1-rc2, llvmorg-4.0.1-rc1 |
|
| #
f8435a9b |
| 13-Mar-2017 |
Peter Collingbourne <peter@pcc.me.uk> |
ELF: Resolve _end symbols correctly.
Fix a bug introduced in r297313 which caused them to resolve to the end of the ELF header in PIEs and DSOs.
Differential Revision: https://reviews.llvm.org/D308
ELF: Resolve _end symbols correctly.
Fix a bug introduced in r297313 which caused them to resolve to the end of the ELF header in PIEs and DSOs.
Differential Revision: https://reviews.llvm.org/D30843
llvm-svn: 297638
show more ...
|
|
Revision tags: llvmorg-4.0.0, llvmorg-4.0.0-rc4, llvmorg-4.0.0-rc3, llvmorg-4.0.0-rc2, llvmorg-4.0.0-rc1, llvmorg-3.9.1, llvmorg-3.9.1-rc3, llvmorg-3.9.1-rc2, llvmorg-3.9.1-rc1 |
|
| #
8fd0196c |
| 23-Nov-2016 |
Ed Maste <emaste@freebsd.org> |
lld: Default image base address to 0x200000 on x86-64
Align to the large page size (known as a superpage or huge page). FreeBSD automatically promotes large, superpage-aligned allocations.
Differen
lld: Default image base address to 0x200000 on x86-64
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
show more ...
|
|
Revision tags: llvmorg-3.9.0, llvmorg-3.9.0-rc3, llvmorg-3.9.0-rc2, llvmorg-3.9.0-rc1, llvmorg-3.8.1, llvmorg-3.8.1-rc1, llvmorg-3.8.0, llvmorg-3.8.0-rc3, llvmorg-3.8.0-rc2, llvmorg-3.8.0-rc1, llvmorg-3.7.1, llvmorg-3.7.1-rc2 |
|
| #
9c8904fb |
| 18-Nov-2015 |
Rafael Espindola <rafael.espindola@gmail.com> |
Rename ld.lld2 to ld.lld since it is the default.
llvm-svn: 253437
|
| #
4b1285c5 |
| 17-Nov-2015 |
Rafael Espindola <rafael.espindola@gmail.com> |
Rename test/elf2 to test/ELF.
llvm-svn: 253313
|