Mohamed Shafi wrote:
> 2009/8/1 Dave Korn <[email protected]>:
>> 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