Page MenuHomeFreeBSD

libelf: correct mips64 test to use ELF header
ClosedPublic

Authored by emaste on Oct 1 2018, 9:00 PM.

Details

Summary

libelf maintains two views of endianness: e_byteorder, and e_ident[EI_DATA] in the ELF header itself. e_byteorder is not necessarily always in sync, so use the ELF header endianness to test for mips64le.

PR: 231790
See also D15734

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

emaste created this revision.Oct 1 2018, 9:00 PM
jhb accepted this revision.Oct 2 2018, 2:29 AM

Use "mips64el" instead of "mips64le" in the commit message. Good sleuthing!

This revision is now accepted and ready to land.Oct 2 2018, 2:29 AM
This revision was automatically updated to reflect the committed changes.

We would also need to check for 64bit-ness prior to using the e_hdr64 field.

emaste added a comment.EditedOct 2 2018, 9:31 PM

We would also need to check for 64bit-ness prior to using the e_hdr64 field.

Note that the original change in D15734 only calls _libelf_is_mips64el in 64-bit cases so in practice it won't be an issue (the test already checked e_ehdr64->e_machine), and I hope we can soon replace it with a general translator as you mentioned earlier. But I could add a safety-belt until that happens.