On Tue, Feb 14, 2023 at 07:54:29PM +0100, Phil Wiggum wrote: > I can't get NOLOAD working any more. > This used to work before binutils_2_36. > > Default linker script 'cc430f5137.ld' is overloaded with a script file > (without -T) > > SECTIONS > { > .infoA (NOLOAD) : {} > INFOA > .infoB (NOLOAD) : {} > INFOB > .infoC (NOLOAD) : {} > INFOC > .infoD (NOLOAD) : {} > INFOD > } > > From ld man page: > If the linker cannot recognize the format of an object file, it > will assume that it is a linker script. A script specified in > this way augments the main linker script used for the link > (either the default linker script or the one specified by using > -T). This feature permits the linker to link against a file > which appears to be an object or an archive, but actually merely > defines some symbol values, or uses "INPUT" or "GROUP" to load > other objects. Specifying a script in this way merely augments > the main linker script, with the extra commands placed after the > main script; use the -T option to replace the default linker > script entirely, but note the effect of the "INSERT" command. > > Default cc430f5137.ld... > .... > .infoA : {} > INFOA /* MSP430 INFO FLASH MEMORY SEGMENTS */ > .infoB : {} > INFOB > .infoC : {} > INFOC > .infoD : {} > INFOD > .... > > Modifying default script with NOLOAD works, but not if I try to overload it. > > > msp430-elf-gcc -Wl,--as-needed -Wl,--no-undefined -mmcu=cc430f5137 > -Wl,--start-group -Wl,--end-group -Wl,--verbose=255 overload-ld/cc430f5137.ld > -Wl,-gc-sections -Wl,-Map,cc430f5137.map main.o -o out
I think you've been affected by a deliberate linker change in the handling of duplicate output sections. What you'll end up with now when using your script is overall the same as a single script with .infoA : {} > INFOA ... .infoA (NOLOAD) : {} > INFOA What that will do is put .infoA sections into the first .infoA output section seen (by the linker orphan section handling since the script doesn't have { *(.infoA) }. This suggests two ways you can fix your extra linker script. 1) Write ".infoA (NOLOAD) : { *(.infoA) } > INFOA" and similarly for the other output sections in your extra script. By specifying the input sections these will match your output section before orphan sections are handled. This modification should work with older linkers too. 2) Add INSERT BEFORE .infoA; at the end of your extra script. -- Alan Modra Australia Development Lab, IBM