Change section flags in linker script

View: New views
3 Messages — Rating Filter:   Alert me  

Change section flags in linker script

by Dobes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I need to make the text sections in my elf file look like data. Currently, I am doing this using objcopy and the "--set-section-flags" flag.  Since my executable has many such text sections that I need to make look like data, I end up having way too many of these flags to pass and it gets ugly, plus it would be nice to not have to take this extra step of calling objcopy.  I would prefer to modify this flag via the linker script, but I cannot figure out how to do this.  To clarify, here is an example of what I start with (from objdump -h):

 29 .text     00008fe8  a0002010  a0002010  0000132d  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, CODE

And this is what I want to end up with:

 29 .text     00008fe8  a0002010  a0002010  0000132d  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

Re: Change section flags in linker script

by Alan Modra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Nov 05, 2009 at 03:55:16PM -0800, Dobes wrote:
>
> I need to make the text sections in my elf file look like data. Currently, I
> am doing this using objcopy and the "--set-section-flags" flag.  Since my
> executable has many such text sections that I need to make look like data, I
> end up having way too many of these flags to pass and it gets ugly, plus it
> would be nice to not have to take this extra step of calling objcopy.  I
> would prefer to modify this flag via the linker script, but I cannot figure
> out how to do this.

No such feature is available.  Of course, since ld is free software,
you could add the feature yourself if you're willing to write some
code.

--
Alan Modra
Australia Development Lab, IBM

Re: Change section flags in linker script

by Bugzilla from jreiser@bitwagon.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> To clarify, here is an example of what I start with
> (from objdump -h):
>
>   29 .text     00008fe8  a0002010  a0002010  0000132d  2**3
>                    CONTENTS, ALLOC, LOAD, READONLY, CODE
>
> And this is what I want to end up with:
>
>   29 .text     00008fe8  a0002010  a0002010  0000132d  2**3
>                    CONTENTS, ALLOC, LOAD, READONLY, DATA

If all you want to do is clear the SHF_EXECINSTR flag,
then that's a very simple app in C (or your favorite language.)

--