Page MenuHomeFreeBSD

Parse MIPS relocations to unbreak kldxref on MIPS.
ClosedPublic

Authored by jhb on Apr 9 2019, 11:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 27, 5:08 PM
Unknown Object (File)
Sep 28 2024, 7:25 PM
Unknown Object (File)
Sep 24 2024, 4:05 AM
Unknown Object (File)
Sep 14 2024, 8:48 PM
Unknown Object (File)
Sep 12 2024, 8:31 AM
Unknown Object (File)
Sep 12 2024, 8:31 AM
Unknown Object (File)
Sep 12 2024, 8:31 AM
Unknown Object (File)
Sep 12 2024, 8:31 AM
Subscribers

Details

Summary

Parse the R_MIPS_32 and R_MIPS_64 relocations. Both Elf_Rel and
Elf_Rela relocations are handled since O32 MIPS uses Elf_Rel while N64
uses Elf_Rela. Note that R_MIPS_32 is only handled for 32-bit mips and
R_MIPS_64 for 64-bit. N32 is untested.

Test Plan
  • kldxref on mips and mips64 instances in qemu. All the warnings and errors on boot are now gone.

Diff Detail

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

Event Timeline

So this looks good to me. Having at least mips64 covered, even if other things are unknown is a win. one question about r_mips_32 to think about.

usr.sbin/kldxref/ef_mips.c
77 โ†—(On Diff #56027)

Do you need a cast here to where to only write 4 bytes instead of 8?

This revision is now accepted and ready to land.Apr 10 2019, 1:24 AM
usr.sbin/kldxref/ef_mips.c
77 โ†—(On Diff #56027)

Hmm, this matches what the kernel code does. I didn't have any relevant R_MIPS_32 relocations in mips64 kernel modules though. Maybe I'll spin up a 32-bit mips qemu instance to see what happens there. It may be that I end up just using an #ifdef on the ABI for R_MIPS_32 vs R_MIPS_64 and the body of the case is the one for R_MIPS_64.

  • Tested and now works on o32 mips. o32 uses Elf_Rel instead of Elf_Rela. I didn't bother supporting R_MIPS_32 on mips64, only for 32-bit. I haven't tested n32, but I also mostly don't care about n32.
This revision now requires review to proceed.Apr 23 2019, 11:49 PM
jhb retitled this revision from Parse simple MIPS relocations to unbreak kldxref on MIPS. to Parse MIPS relocations to unbreak kldxref on MIPS..Apr 23 2019, 11:51 PM
jhb edited the summary of this revision. (Show Details)
jhb edited the test plan for this revision. (Show Details)

OK. this looks saner to me now. I'd expect it to work, so ship it !

This revision is now accepted and ready to land.Apr 24 2019, 11:15 PM
This revision was automatically updated to reflect the committed changes.
In D19870#430603, @jhb wrote:
  • Tested and now works on o32 mips. o32 uses Elf_Rel instead of Elf_Rela. I didn't bother supporting R_MIPS_32 on mips64, only for 32-bit. I haven't tested n32, but I also mostly don't care about n32.

n32 has 64-bit registers, but 32-bit pointers. It doesn't define LP64, nor does it have 64-bit addresses, so it shouldn't ever generate R_MIPS_64 entries. We should be fine, though I agree that an n32 *KERNEL* is an odd duck.