Page MenuHomeFreeBSD

loader: fix endianness conversion
ClosedPublic

Authored by royger on Feb 8 2018, 5:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 22 2023, 11:49 PM
Unknown Object (File)
Jul 7 2023, 11:54 AM
Unknown Object (File)
Jan 29 2023, 10:17 AM
Unknown Object (File)
Jan 9 2023, 2:15 AM
Unknown Object (File)
Jan 4 2023, 11:24 PM
Unknown Object (File)
Nov 27 2022, 9:49 AM
Subscribers

Details

Summary

r328536 broke symbol loading on amd64 at least (and probably other
arches). r328826 contained the problem to ppc only by adding
pre-processors guards.

Fix this properly by moving the endianness conversion to separate
helper functions, and make the conversion more robust by using sizeof
instead of having to manually code the size of each field.

Finally list the fields in each structure in a macro in order to avoid
code repetition.

Sponsored by: Citrix Systems R&D

Test Plan

Tested on AMD64 only, seems to WFM.

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Feb 8 2018, 5:39 PM

Existing indentation in this file is a mess, but there are a couple of new cases that don't match either of the two existing styles. I suggest tweaking this change to match the surrounding cases, and then someone (@imp or me, perhaps) should follow up with reformatting the portions that don't conform to style(9).

stand/common/load_elf.c
238 ↗(On Diff #39046)

indentation - I think this one should be 2 tabs

510 ↗(On Diff #39046)

indentation

587–588 ↗(On Diff #39046)

indentation

This works in my QEMU test case and LGTM, modulo indentation nits.

Existing indentation in this file is a mess, but there are a couple of new cases that don't match either of the two existing styles. I suggest tweaking this change to match the surrounding cases, and then someone (@imp or me, perhaps) should follow up with reformatting the portions that don't conform to style(9).

Thanks! I've fixed those, but maybe we should think about re-formatting the whole file to match the coding standards. I think @imp has already done that for other loader related files.

stand/common/load_elf.c
154 ↗(On Diff #39046)

I've constified ehdr here and below.

This revision was automatically updated to reflect the committed changes.