Page MenuHomeFreeBSD

ldscript.powerpc*: Only put .dynamic in PT_DYNAMIC
ClosedPublic

Authored by jrtc27 on Dec 14 2023, 4:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 23 2024, 11:45 PM
Unknown Object (File)
Jan 28 2024, 6:44 AM
Unknown Object (File)
Jan 26 2024, 12:19 AM
Unknown Object (File)
Jan 10 2024, 9:29 PM
Unknown Object (File)
Dec 24 2023, 6:06 PM
Subscribers

Details

Summary

Currently there are a few output sections left as implicitly using
:kernel :dynamic before :kernel on its own is used again, which means
they end up in both the PT_LOAD and the PT_DYNAMIC segments, causing
kldxref to treat the kernel as invalid. Thus, hoist the :kernel to the
very next section to ensure only .dynamic is in PT_DYNAMIC.

Whilst here, sync ldscript.powerpc64le with ldscript.powerpc64 to pick
up various fixes that were presumably made between the start of the
powerpc64le port and it being committed and got missed.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Was this broken with the pre-libelf kldxref as well?

In D43066#981966, @jhb wrote:

Was this broken with the pre-libelf kldxref as well?

I don't have a system to test on, and don't hugely want to deal with QEMU for it, but it's a new check in the libelf kldxref, and since .dynamic is terminated by a DT_NULL entry it should have stopped at the right point in the too big segment. So I believe this is a latent oddity in the kernel that is newly exposed by kldxref.

sys/conf/ldscript.powerpc
87

maybe we should simplify based on this comment?

In D43066#981966, @jhb wrote:

Was this broken with the pre-libelf kldxref as well?

I don't have a system to test on, and don't hugely want to deal with QEMU for it, but it's a new check in the libelf kldxref, and since .dynamic is terminated by a DT_NULL entry it should have stopped at the right point in the too big segment. So I believe this is a latent oddity in the kernel that is newly exposed by kldxref.

Hmm, I think it's the check I added that the SHT_DYNAMIC section has the same start/size as the PT_DYNAMIC segment. I could perhaps relax that to allow a larger PT_DYNAMIC segment size to support older kernels without your fix.

In D43066#982359, @jhb wrote:
In D43066#981966, @jhb wrote:

Was this broken with the pre-libelf kldxref as well?

I don't have a system to test on, and don't hugely want to deal with QEMU for it, but it's a new check in the libelf kldxref, and since .dynamic is terminated by a DT_NULL entry it should have stopped at the right point in the too big segment. So I believe this is a latent oddity in the kernel that is newly exposed by kldxref.

Hmm, I think it's the check I added that the SHT_DYNAMIC section has the same start/size as the PT_DYNAMIC segment. I could perhaps relax that to allow a larger PT_DYNAMIC segment size to support older kernels without your fix.

I've relaxed the check for powerpc in D43123. I think we still want this fix regardless.

This revision is now accepted and ready to land.Dec 19 2023, 7:09 PM