Re: Is there another way to put functions to a specifed section?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux