This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Output sections
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: Mohamed Shafi <shafitvm at gmail dot com>
- Cc: Dave Korn <dave dot korn dot cygwin at googlemail dot com>, GCC <gcc at gcc dot gnu dot org>
- Date: Sat, 01 Aug 2009 08:21:43 +0100
- Subject: Re: Output sections
- References: <ba0bd44d0907180149s2f135eccp4be437f1f34351e2@mail.gmail.com> <4A61B97A.7030009@gmail.com> <ba0bd44d0907310642pead6b79md2cb30c11ae383c6@mail.gmail.com> <4A73E2A2.3070202@gmail.com> <ba0bd44d0907312337x2bd909b1k63629713926b846b@mail.gmail.com>
Mohamed Shafi wrote:
> 2009/8/1 Dave Korn <dave.korn.cygwin@googlemail.com>:
>> Mohamed Shafi wrote:
>>> I am looking for adding something to the end of each section in the
>>> generated .s file. Using TARGET_ASM_NAMED_SECTION i will be able to
>>> keep track of the sections that are being emitted. But from
>>> TARGET_ASM_FILE_END hook how can i re-enter into each section. Are the
>>> sections stored in some global variable?
>> I'm not sure I understand the question. You "enter a section" simply by
>> emitting the correct .section directive into the asm output. You re-enter it by
>> the same method.
> Ok, Then i don't understand your solution.
Ah, it looks like I didn't quite understand your problem.
>>> you could use the TARGET_ASM_FILE_END hook to output
>>> directives that re-enter each used section and then output your new directive.
>
> if i want to do the following in the assembly output
>
> section .code
> .....
> .....
> ......
> section_end
I thought you just wanted to have
.section .code
section_end
.section .data
section_end
... etc. for all used sections, at the very end of the file; after all, all the
contributions to a section get concatenated in the assembler. Now you seem to
be saying that you want to have multiple section_end directives throughout the
file, every time the current section changes.
> you are saying that if i emit a section directive the compiler will
> switch to the previously emitted section and then i have to somehow
> seek to the end of that section and emit my 'section_end' directive?
I think you may need to re-read the assembler manual about sections, you are a
little confused about the concepts. The compiler doesn't really "switch"
anything; the compiler emits ".section" directives, in response to which the
*assembler* switches to emit code in the chosen section. The compiler doesn't
keep track of sections; it just randomly emits directives for whichever one it
wants the assembly output to go into at any given time, according to whether
it's generating the assembly for a function or a variable or other data object.
cheers,
DaveK