Specify elf section flag in linker script.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Specify elf section flag in linker script.

Post 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
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Specify elf section flag in linker script.

Post 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
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Post Reply