Page MenuHomeFreeBSD

Fully handle the special encoding of GOT[1] on mips64.
ClosedPublic

Authored by jhb on Feb 21 2017, 10:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 26 2024, 12:07 PM
Unknown Object (File)
Feb 26 2024, 12:05 PM
Unknown Object (File)
Jan 26 2024, 12:27 PM
Unknown Object (File)
Jan 26 2024, 12:26 PM
Unknown Object (File)
Jan 26 2024, 11:53 AM
Unknown Object (File)
Jan 26 2024, 11:11 AM
Unknown Object (File)
Dec 20 2023, 12:18 AM
Unknown Object (File)
Nov 18 2023, 5:31 AM
Subscribers

Details

Summary

Fully handle the special encoding of GOT[1] on mips64.

The MIPS ABI does not require the second GOT entry to be reserved for use
by the runtime linker as on other architectures. Instead, static linkers
use a special value in the second GOT entry to indicate if the entry is
reserved. This value is supposed to consist of an address with the MSB
set and the rest of the bits all zero which is an invalid user address.

However, the old binutils currently in the tree uses the 32-bit mask value
(2^31) on 64-bit MIPS instead of 2^63. This was fixed in upstream
binutils in 2008 to use 2^63 on 64-bit MIPS.

The first part of this change changes the runtime check in init_pltgot()
to check for both values (2^31 and 2^63) when deciding whether to store
the current object pointer in GOT[1] which fixes dynamic N64 binaries
compiled with modern binutils.

However, the initial version of this fix exposed another related bug in
that _rtld_relocate_nonplt_self() was only checking for the new value
(2^63) in GOT[1] and incorrectly treated GOT[1] as a local GOT entry
(and did not relocate the final local GOT entry). To handle this, fix
all of the places that check for GOT[1]'s status to use the same macro
that checks for both values on N64.

Note: I wonder if we should just remove all of the checks and assume that
GOT[1] is always reserved on FreeBSD? Are there any FreeBSD binaries where
GOT[1] wouldn't be reserved?

Test Plan
  • able to boot n64 worlds under qemu compiled with both gcc4.2.1 and gcc6.

Diff Detail

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

Event Timeline

jhb retitled this revision from to Fully handle the special encoding of GOT[1] on mips64..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added a reviewer: kan.
jhb added subscribers: sbruno, imp, adrian.
kan edited edge metadata.
This revision is now accepted and ready to land.Feb 22 2017, 7:33 PM
imp added a reviewer: imp.
This revision was automatically updated to reflect the committed changes.