Page MenuHomeFreeBSD

Handle relocations for newer non-PIC MIPS ABI.
ClosedPublic

Authored by jhb on Sep 11 2017, 11:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 11:20 PM
Unknown Object (File)
Dec 20 2023, 2:56 AM
Unknown Object (File)
Dec 16 2023, 12:49 AM
Unknown Object (File)
Sep 26 2023, 10:10 PM
Unknown Object (File)
Sep 4 2023, 10:34 PM
Unknown Object (File)
Sep 4 2023, 10:30 PM
Unknown Object (File)
Sep 4 2023, 10:28 PM
Unknown Object (File)
Aug 30 2023, 10:22 AM
Subscribers

Details

Summary

Newer binutils supports extensions to the MIPS ABI for non-PIC code
that is used when compiling O32 binaries with clang 5 (but not used
for N64 oddly enough). These extensions require support for
R_MIPS_COPY relocations as well as a second PLT GOT using
R_MIPS_JUMP_SLOT relocations.

For R_MIPS_COPY, use the same approach as on other architectures where
fixups are deferred to the MD do_copy_relocations.

The additional PLT GOT for jump slots is located in a .got.plt section
which is identified by a DT_MIPS_PLTGOT dynamic entry. This GOT also
requires fixups for the first two GOT entries just as the normal GOT.
However, the entry point for this second GOT uses a different calling
convention. Rather than passing an offset into the GOT, it passes an
offset into the .rel.plt section. This requires a second entry point
(_rtld_pltbind_start) which calls the normal _rtld_bind() rather than
_mips_rtld_bind(). This also means providing a real version of
reloc_jmpslot() which is used by _rtld_bind().

In addition, add real implementions of reloc_plt() and reloc_jmpslots()
which walk .rel.plt handling R_MIPS_JUMP_SLOT relocations.

Test Plan
  • booted mips o32 world built with clang + external binutils in qemu. dynamic binaries such as /bin/sh used both of these relocations (so I couldn't even get into single user mode before fixing this)
  • Note that I have only gotten clang to emit this for O32, so N32 and N64 are not tested, but the calling conventions should be identical (based on comments in glibc), so I believe the asm for N32 and N64 to be correct.

Diff Detail

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

Event Timeline

kib added inline comments.
libexec/rtld-elf/mips/reloc.c
94 โ†—(On Diff #32942)

blank line is needed

160 โ†—(On Diff #32942)

return (0);

This revision is now accepted and ready to land.Sep 12 2017, 12:57 PM
jhb marked 2 inline comments as done.Sep 12 2017, 5:45 PM
This revision was automatically updated to reflect the committed changes.