RE: Using C on x86-64, why emit .text for global data?

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

 



Thank you, Jim.

So I guess I can conclude that when writing directly in assembly language, I don't need that extra .text. I'm sure that if I do something wrong with the various directives (.section .rodata, .data, .globl, .comm, etc.) the assembler and loader will tell me. It's just that this is for a book I'm writing, so I wanted to make sure I understand the situation to avoid saying something stupid in print.

Bob

> -----Original Message-----
> From: Jim Wilson <jimw@xxxxxxxxxx>
> Sent: Friday, September 27, 2019 6:57 PM
> To: Bob Plantz <rgplantz@xxxxxxxxxxx>
> Cc: gcc-help@xxxxxxxxxxx
> Subject: Re: Using C on x86-64, why emit .text for global data?
> 
> On Fri, Sep 27, 2019 at 10:44 AM Bob Plantz <rgplantz@xxxxxxxxxxx> wrote:
> > Why does gcc emit an extra .text before the global data?
> >
> > .file "globalData.c"
> > .text
> > .globl x
> > .data
> 
> Compile an empty file, and you will see that it starts with the same two lines.
> This probably just simplifies logic somewhere else in the compiler to force
> the assembler into a known state at the beginning, regardless of what is
> actually in the C file.  There is no harm in emitting an extra unnecessary .text
> directive to the assembler.
> 
> Jim




[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