Linker Script Question

May 01, 2009 3 Replies

For the sample linker script below I have two questions....


1) How can I make sure the image between the end of output1 and the beginning of output2 is filled with 0xff - or a value of my chosing?


2) Even though output2 is only small, how can I force the image to extend up to the end of bootsec and be padded with 0xff - or a value of my chosing?



All day I've been trying various things from the ld manual but have nothing to show for it :-(


MEMORY { bootsec (wx) : ORIGIN =0x00000000, LENGTH = 16k }



SECTIONS { output1 0x0000 : { bootstrap.o(.text) } >bootsec =0xffffffff



output2 0x3e00 : { version_string.o(.data) } >bootsec =0xffffffff }


Did you try adding, inside output*, something like: .=3Dlast_address long(0xffffffff)

Hope that helps, Best Regards, Dave

I did try bumping the current address as you suggest but that didn't work. I finally got the answer from a reply in comp.sys.arm

It turns out objcopy has the options --gap-fill and --pad-to which do exactly what I want.

So doing the objcopy post-link fits the bill.

Did you follow bumping the address with something like LONG(..) so that there is an actual gap in the area ?

Anyway, glad you got objcopy to do it ! Best Regards, Dave

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required