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

Jim Wilson jimw@sifive.com
Sat Sep 28 01:56:00 GMT 2019


On Fri, Sep 27, 2019 at 10:44 AM Bob Plantz <rgplantz@outlook.com> 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



More information about the Gcc-help mailing list