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
F102162749: D43066.diff
Fri, Nov 8, 9:38 AM
Unknown Object (File)
Fri, Oct 25, 3:59 AM
Unknown Object (File)
Tue, Oct 22, 5:36 PM
Unknown Object (File)
Sun, Oct 20, 2:39 AM
Unknown Object (File)
Fri, Oct 11, 12:05 AM
Unknown Object (File)
Fri, Oct 11, 12:05 AM
Unknown Object (File)
Fri, Oct 11, 12:04 AM
Unknown Object (File)
Thu, Oct 10, 11:30 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 Passed
Unit
No Test Coverage
Build Status
Buildable 54954
Build 51843: arc lint + arc unit

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