PLT Problems in uBoot on MCF548x
Peter LaDow
pladow@gmail.com
Wed Jul 31 14:59:12 GMT 2024
With "readelf -e" there is a single RELA section: .rela.dyn. This is
handled later in the code when the code itself is relocated to RAM.
At this point, the code is executing from flash.
There are R_68K_RELATIVE, R_68K_32, and R_68K_JMP_SLOT entries when I
use "readelf -r."
One of these does map to memset. The first lookup in the PLT:
23c0c: 203c 0000 c85a movel #51290,%d0
23c12: 207b 08fa moveal %pc@(23c0e <.plt+0x13a>,%d0:l),%a0
23c16: 4ed0 jmp %a0@
Does map to memset:
$ m68k-linux-gnu-readelf -r u-boot
...
00030468 00005315 R_68K_JMP_SLOT 0001f0b0 memset + 0
...
And indeed, memset is at 0x1f0b0:
$ m68k-linux-gnu-nm -n u-boot
...
0001f0b0 T memset
...
But it's not clear to me how this information is used by the PLT.
I'm not sure what you mean about "relocations against the relevant
.got.plt entry." I don't see anything that points to any addresses in
.got.plt.
And finally, your question about if the "relocations applied early
enough." I don't think so. The startup code does not do any
relocations at this point. There is code to relocate uboot out of
flash to RAM, but we aren't there yet. This uses __rel_dyn_start and
__rel_dyn_end, but this happens after the system is configured (SDRAM,
etc.). Indeed, relocation is the very last step before entering the
main loop.
There is another platform, the MCF5445x, which I've used as a model.
This too uses PLT (rather than GOT160 relocations as other Coldfire
platforms do). My startup code is nearly identical (I stripped on the
NAND boot and SBF). And that code does not do any fixups or other
relocations until later.
On Tue, Jul 30, 2024 at 5:03 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Tue, Jul 30, 2024 at 12:28:13PM -0700, Peter LaDow wrote:
> > 68k-linux-ld.bfd -n -pie -z noexecstack --no-warn-rwx-segments
> > --gc-sections -pie -Bstatic --no-dynamic-linker -z notext
> > --build-id=none -Ttext 0x0 -o u-boot -T u-boot.lds
> > arch/m68k/cpu/mcf548x/start.o --whole-archive (... snipped for
> > brevity) --no-whole-archive arch/m68k/lib/lib.a -Map u-boot.map
>
> Have you examined u-boot using readelf to see whether there are any
> RELA type sections? If so, do you see a relocation against the
> relevant .got.plt entry? Also, are these relocations applied early
> enough, ie. before the board_init.c memset call?
>
> --
> Alan Modra
--
To love for the sake of being loved is human, but to love for the sake
of loving is angelic. -- Alphonse de Lamartine.
More information about the Binutils
mailing list