Page MenuHomeFreeBSD

Fix booting the arm64 kernel when built with clang 3.9.0

Authored by andrew on Nov 23 2016, 11:45 AM.
Referenced Files
Unknown Object (File)
Wed, Sep 20, 12:15 AM
Unknown Object (File)
Sat, Sep 2, 8:15 PM
Unknown Object (File)
Aug 26 2023, 5:11 AM
Unknown Object (File)
Jul 30 2023, 4:55 AM
Unknown Object (File)
Jul 9 2023, 6:07 PM
Unknown Object (File)
Jul 9 2023, 6:03 PM
Unknown Object (File)
Jul 9 2023, 6:03 PM
Unknown Object (File)
Jul 9 2023, 5:56 PM



Clang 3.9.0 changes how weak extern is handled. They now use the got to
handle them. This is a problem as ld.bfd doesn't fill out any default
value in the got so pointers become NULL. This caused the kernel to fail
to boot as we use this in linker sets.

This fixes the issue by setting s default value in the got. The kernel
still loads data through it, but because we always load it at a fixed virtual
address the address it finds is valid.

There is an LLVM bug with some background information at the following,
however I think this is in fact a binutils bug the change in behaviour has

Diff Detail

rP FreeBSD ports repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

andrew retitled this revision from to Fix booting the arm64 kernel when built with clang 3.9.0.
andrew updated this object.
andrew edited the test plan for this revision. (Show Details)
andrew added a reviewer: bapt.
andrew added subscribers: emaste, dim.

Post this for upstream binutils also? @jhb can commit it there if it's approved.

I'm not sure this is the correct fix for upstream. I don't think ld should be generating relocations for weak extern pointing at these linker sets, however that would need someone that knows more about ld internals than I do.

@bapt ping. rS309124 has updated clang breaking the arm64 kernel when built with binutils without this change.

bapt edited edge metadata.
This revision is now accepted and ready to land.Nov 28 2016, 6:54 PM

Patch tested successfully on my end.

This revision was automatically updated to reflect the committed changes.

I was trying to follow the discussion at llvm bug 30848, but the thread ran cold - there are still some unanswered investigation questions.