* Is there another way to put functions to a specifed section?
@ 2008-02-02 8:15 PRC
2008-02-02 8:59 ` Sam Ravnborg
0 siblings, 1 reply; 2+ messages in thread
From: PRC @ 2008-02-02 8:15 UTC (permalink / raw)
To: gcc-help
Is there another way to inform gcc to put all functions in the same source file
to a specified section, like ".mytext", without defining each function with
__attribute__(( section(".mytext") ))?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Is there another way to put functions to a specifed section?
2008-02-02 8:15 Is there another way to put functions to a specifed section? PRC
@ 2008-02-02 8:59 ` Sam Ravnborg
0 siblings, 0 replies; 2+ messages in thread
From: Sam Ravnborg @ 2008-02-02 8:59 UTC (permalink / raw)
To: PRC; +Cc: gcc-help
HI PRC.
On Sat, Feb 02, 2008 at 04:14:27PM +0800, PRC wrote:
> Is there another way to inform gcc to put all functions in the same source file
> to a specified section, like ".mytext", without defining each function with
> __attribute__(( section(".mytext") ))?
I sounds like a job for objcopy. See following objcopy option:
--rename-section oldname=newname[,flags]
Rename a section from oldname to newname, optionally changing the sectionâs flags to flags in the process.
This has the advantage over usng a linker script to perform the rename in that the output stays as an object
file and does not become a linked executable.
This option is particularly helpful when the input format is binary, since this will always create a section
called .data. If for example, you wanted instead to create a section called .rodata containing binary data
you could use the following command line to achieve it:
objcopy -I binary -O <output_format> -B <architecture> \
--rename-section .data=.rodata,alloc,load,readonly,data,contents \
<input_binary_file> <output_object_file>
Sam
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-02 8:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-02 8:15 Is there another way to put functions to a specifed section? PRC
2008-02-02 8:59 ` Sam Ravnborg
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).