RWX load segment MSP430 back-end
Nick Clifton
nickc@redhat.com
Thu Jan 19 11:45:52 GMT 2023
Hi Orlando,
> I ran into a rather puzzling issue with ld.bfd for the MSP430 target
For problems like this it is really best if you can file a bug report
with the binutils bugzilla system. That way, if there is an issue,
we can track it, and future readers can search for the solution.
> /usr/bin/msp430-elf-ld: warning: binary.elf has a LOAD segment with RWX permissions
> $ msp430-elf-readelf -l binary.elf
> Program Headers:
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x000000 0x0000c14c 0x0000c14c 0x0016e 0x0016e RWE 0x4
If you add the -S option to the msp430-elf-readelf command, it will also
tell you which sections are mapped to that segment:
Section to Segment mapping:
Segment Sections...
00 .rodata2 .text
> Well, indeed there is something that gets placed at 0xc14c that is read write and executable. However, the MSP430FR5739 has nothing on that memory region! In fact, looking
> at the linker scripts reveals nothing that should be placed there, unless I am missing something of course.
This does assume that the linker script for the msp430fr5397 has been used.
It is possible that a different script it being used. Adding -v to the
final msp43-elf-gcc command line should you check that.
Even better if you add -Wl,-Map,binary.map the linker will create a map file
(called binary.map) which will show you what went where during the link.
> In any case, I have no idea where extraneous segment is coming from.
My best guess is that the segment is meant to map onto the FRAM of the
MSP430FR5739. But for some reason the segment's start address is being
pushed backwards to earlier in memory. No idea why.
> I did notice that a patch was submitted to treat the cris*-elf backend in a special way by defaulting to --no-warn-rwx-segment which I
> guess could be done as well for the MSP430.
That could be done. But it is only a warning message - it should not
affect the outcome of the link at all. (I should also note that there
is a configure-time option to disable this warning, so it is possible
to build a msp430-elf-ld which does not warn, without adding any patches
to the binutils sources).
Of course if your programs are working, then you can safely ignore this
issue. (Assuming that there are no security concerns over the writeable,
executable memory). You can always add -Wl,--no-warn-rwx-segment to the
gcc command line if you want to turn off the warning. If you are worried
however then please refile this email as a bug report, and if you can,
include a copy of the linker map and linker script.
Cheers
Nick
More information about the Binutils
mailing list