public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Orlando Arias <orlandoarias@gmail.com>, binutils@sourceware.org
Subject: Re: RWX load segment MSP430 back-end
Date: Thu, 19 Jan 2023 11:45:52 +0000	[thread overview]
Message-ID: <fdbb2fd3-e1d8-ad83-0ace-3004938c1301@redhat.com> (raw)
In-Reply-To: <d9d341e2-0b92-a158-0b9d-e702978b1fe4@gmail.com>

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


      reply	other threads:[~2023-01-19 11:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 16:31 Orlando Arias
2023-01-19 11:45 ` Nick Clifton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fdbb2fd3-e1d8-ad83-0ace-3004938c1301@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=orlandoarias@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).