<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/lld/test/ELF/pre_init_fini_array_missing.s, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[ELF] Make start/stop symbols retain associated discardable output sections</title>
<updated>2024-07-02T17:58:24+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-07-02T17:58:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=fdd319655359b005889abf40d1d8a54fbd56059e'/>
<id>fdd319655359b005889abf40d1d8a54fbd56059e</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[X86InstPrinter] Change printPCRelImm to print the target address in hexadecimal form</title>
<updated>2020-03-26T15:28:59+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>maskray@google.com</email>
</author>
<published>2020-03-22T22:03:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=87de9a0786d922a1b52db6cd8b12f642d1d00d85'/>
<id>87de9a0786d922a1b52db6cd8b12f642d1d00d85</id>
<content type='text'>
```
// 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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
```
// 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
</pre>
</div>
</content>
</entry>
<entry>
<title>[llvm-objdump] -d: print `00000000 &lt;foo&gt;:` instead of `00000000 foo:`</title>
<updated>2020-03-06T02:05:28+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>maskray@google.com</email>
</author>
<published>2020-03-05T22:18:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=71e2ca6e32105b35aeadeab25010e8f999c47c23'/>
<id>71e2ca6e32105b35aeadeab25010e8f999c47c23</id>
<content type='text'>
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: &lt;&gt; has metalinguistic connotation. it just "feels right"

Reviewed By: rupprecht

Differential Revision: https://reviews.llvm.org/D75713
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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: &lt;&gt; has metalinguistic connotation. it just "feels right"

Reviewed By: rupprecht

Differential Revision: https://reviews.llvm.org/D75713
</pre>
</div>
</content>
</entry>
<entry>
<title>[ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_X86_64</title>
<updated>2019-09-16T07:05:34+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>maskray@google.com</email>
</author>
<published>2019-09-16T07:05:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d4306e90cb18f663342068a4ad83ba42545dbf01'/>
<id>d4306e90cb18f663342068a4ad83ba42545dbf01</id>
<content type='text'>
Port the D64906 technique to EM_X86_64.

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

llvm-svn: 371958
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Port the D64906 technique to EM_X86_64.

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

llvm-svn: 371958
</pre>
</div>
</content>
</entry>
<entry>
<title>[ELF][test] Improve tests</title>
<updated>2019-09-07T10:42:11+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>maskray@google.com</email>
</author>
<published>2019-09-07T10:42:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0e79890d9b5aef4466d572458c0fbb6031b991f6'/>
<id>0e79890d9b5aef4466d572458c0fbb6031b991f6</id>
<content type='text'>
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 =&gt; 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 =&gt; x86-64-gotpc-relax-und-dso.s

llvm-svn: 371299
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 =&gt; 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 =&gt; x86-64-gotpc-relax-und-dso.s

llvm-svn: 371299
</pre>
</div>
</content>
</entry>
<entry>
<title>[llvm-objdump] Print newlines before and after "Disassembly of section ...:"</title>
<updated>2019-05-01T10:40:48+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>maskray@google.com</email>
</author>
<published>2019-05-01T10:40:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5387c2cd17b2fb63df81298527614795ffc0abbb'/>
<id>5387c2cd17b2fb63df81298527614795ffc0abbb</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ELF] Move `// REQUIRES:` line to the top</title>
<updated>2018-06-26T22:20:04+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>maskray@google.com</email>
</author>
<published>2018-06-26T22:20:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b6772b86e285177bc2e44fd49b5a6b228c1e5d9a'/>
<id>b6772b86e285177bc2e44fd49b5a6b228c1e5d9a</id>
<content type='text'>
llvm-svn: 335676
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
llvm-svn: 335676
</pre>
</div>
</content>
</entry>
<entry>
<title>Mitigate relocation overflow [part 2 of 2]</title>
<updated>2018-05-18T03:01:06+00:00</updated>
<author>
<name>Han Shen</name>
<email>shenhan@google.com</email>
</author>
<published>2018-05-18T03:01:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3aede9283cc0a7cc1788c29e040e0f4e7439ba96'/>
<id>3aede9283cc0a7cc1788c29e040e0f4e7439ba96</id>
<content type='text'>
_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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
_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
</pre>
</div>
</content>
</entry>
<entry>
<title>ELF: Resolve _end symbols correctly.</title>
<updated>2017-03-13T16:40:20+00:00</updated>
<author>
<name>Peter Collingbourne</name>
<email>peter@pcc.me.uk</email>
</author>
<published>2017-03-13T16:40:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f8435a9bda034148e1224d3cb167f33a06616936'/>
<id>f8435a9bda034148e1224d3cb167f33a06616936</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>lld: Default image base address to 0x200000 on x86-64</title>
<updated>2016-11-23T17:44:02+00:00</updated>
<author>
<name>Ed Maste</name>
<email>emaste@freebsd.org</email>
</author>
<published>2016-11-23T17:44:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8fd0196c6fd1bb3fed20418ba319677b66645d9c'/>
<id>8fd0196c6fd1bb3fed20418ba319677b66645d9c</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
</feed>
