Page 1 of 1

Specify elf section flag in linker script.

Posted: Fri Jul 01, 2011 3:27 am
by torshie
Hi,
Anyone knows how to specify section flags(Allocate/Writable/eXecutable) in linker script? I found out GNU ld does set some flags to the "magic" sections, for example, it will set flags "AX" for .text & .init section. But GNU ld won't set any flags for sections with customized names, for example .mykernel section.

My elf loader relies on the "A" flag to work. If the "A" flag isn't set, it won't copy data to memory. I really don't want to parse the section name, it's much more complicated.

Thanks
torshie

Re: Specify elf section flag in linker script.

Posted: Fri Jul 01, 2011 7:24 am
by xenos
I remember that there is a way to specify flags for memory regions in ld and flags for sections in as - which is probably not quite what you want.

Alternatively you could set the correct section flags using objcopy after linking:

Code: Select all

objcopy --set-section-flags section=... infile outfile