Article View: gnu.gcc.help
Article #50483Gas query - allocating data in segments...
From: Killian Murphy
Date: Fri, 24 Sep 1993 22:26
Date: Fri, 24 Sep 1993 22:26
58 lines
2751 bytes
2751 bytes
Hi,
[
FYI: uname -a: SunOS realgar 4.1.3 2 sun4c
gcc 2.3.3
GNU assembler version 1.38
]
I am trying to allocate data using "asm" directives in gcc, in order
to get gas to place the data into the executable.
The context for this is to place rcs Id strings into the executable. I
want to do this using asm instructions because the compiler generates
lots of unused identifier type warnings when static char *rcsid="$Id$"
is used, and this cannot be done at all to allow header file id's to
be seen, as multiple headers may be included. Sure, each header could
use a unique name, but hey, that wouldn't be a challenge ...
So instead, I want to do something of the form:
asm(" .ascii \"$Id$\"");
in both headers and code, via an include file. However, I am a little
worried about doing this, as I don't want to put the string into the
middle of program text, if, for example, a person for some strange
reason decides to include the file in the middle of a function or
something.
To fix this, I need to select the data segment, like so...
asm(" .data");
asm(" .ascii \"$Id$\"");
However, this leaves the assembler writing to the data segment
following the statements (or does it? Does it revert to whatever it
wants following the asm statement?).
In order to fix this, I could select .text after the .ascii. However,
this may screw up the assembler if it was writing to the data segment
before the asm instructions.
So, is there any way I can do this, by using an header file containing
statements like the above, so that people will not ruin their lives if
they don't include the file in a civilised part of their code? (ie: at
the top of the file, outside of any functions ..)
Thanks for any help,
Killian.
--
------------------------------------------------------------------------------
Killian Murphy | "Romeo Rodriguez squares his shoulders, curses Jesus,
killian@epcc.ed.ac.uk | runs a comb through his black pony-tail", Lou Reed
------------------------------------------------------------------------------
Technical Details
Message-ID:
<KILLIAN.93Sep24232641@realgar.epcc.ed.ac.uk>Path:
arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!agate!doc.ic.ac.uk!uknet!festival!dcs.ed.ac.uk!newshost.dcs.ed.ac.uk!killianShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,e2fa43488dc69896,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-09-24 16:40:42 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!agate!doc.ic.ac.uk!uknet!festival!dcs.ed.ac.uk!newshost.dcs.ed.ac.uk!killian From: killian@realgar.epcc.ed.ac.uk (Killian Murphy) Subject: Gas query - allocating data in segments... Message-ID: <KILLIAN.93Sep24232641@realgar.epcc.ed.ac.uk> Sender: cnews@dcs.ed.ac.uk (UseNet News Admin) Organization: Department of Computer Science, Edinburgh University Date: Fri, 24 Sep 1993 22:26:41 GMT Lines: 59