Page MenuHomeFreeBSD

Apply upstream lld fixes for correct _end handling
ClosedPublic

Authored by dim on Dec 12 2017, 8:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 29, 1:41 PM
Unknown Object (File)
Tue, Oct 29, 12:27 PM
Unknown Object (File)
Tue, Oct 29, 12:12 PM
Unknown Object (File)
Oct 5 2024, 8:36 PM
Unknown Object (File)
Sep 14 2024, 12:15 PM
Unknown Object (File)
Sep 5 2024, 1:17 PM
Unknown Object (File)
Aug 30 2024, 5:46 AM
Unknown Object (File)
Aug 15 2024, 1:52 PM
Subscribers

Details

Summary

This backports the following two fixes from upstream lld:

------------------------------------------------------------------------
r315334 | rafael | 2017-10-10 19:27:34 +0200 (Tue, 10 Oct 2017) | 12 lines

Don't create a dummy __tls_get_addr.

We just don't need one with the current setup.

We only error on undefined references that are used by some
relocation.

If we managed to relax all uses of __tls_get_addr, no relocation uses
it and we don't produce an error.

This is less code and fixes the case were we fail to relax. Before we
would produce a broken output, but now we produce an error.
------------------------------------------------------------------------
r320390 | rafael | 2017-12-11 18:23:28 +0100 (Mon, 11 Dec 2017) | 18 lines

Create reserved symbols early so they can be versioned.

This fixes pr35570.

We were creating these symbols after parsing version scripts, so they
could not be versioned.

We cannot move the version script parsing later because we need it for
lto.

One option is to move both addReservedSymbols and
createSyntheticSections earlier. The disadvantage is that some
sections created by createSyntheticSections replace other input
sections. For example, gdb index replaces .debug_gnu_pubnames, so it
wants to run after gc sections so that it can set S->Live to false.

What this patch does instead is to move just the ElfHeader creation
early.
------------------------------------------------------------------------

This should ensure that reserved symbols such as _end, _edata etc
get correctly placed into executables, making brk(2) and sbrk(2) work,
and thereby fixing programs that use these, such as emacs.

Test Plan

build world, install, build ports, run them :)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Adding two more follow-up fixes from upstream:

------------------------------------------------------------------------
r320412 | rafael | 2017-12-11 20:45:36 +0100 (Mon, 11 Dec 2017) | 6 lines

Handle symbols pointing to output sections.

Now that gc sections runs after linker defined symbols are added it
can see symbols that point to an OutputSection.

Should fix a bot failure.
------------------------------------------------------------------------
r320431 | pcc | 2017-12-11 23:47:43 +0100 (Mon, 11 Dec 2017) | 5 lines

ELF: Do not follow relocation edges to output sections during GC.

This fixes an assertion error introduced by r320390.

Differential Revision: https://reviews.llvm.org/D41095
------------------------------------------------------------------------

This should hopefully fix the assertions occurring in garbage collection.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 13 2017, 7:04 PM
This revision was automatically updated to reflect the committed changes.