Article View: gnu.gcc.help
Article #52227How to generate PIC code for initial data?
From: Jan Bengtsson
Date: Wed, 13 Jan 1993 13:00
Date: Wed, 13 Jan 1993 13:00
75 lines
2475 bytes
2475 bytes
I am trying to adapt gcc to produce PIC code for our company's
proprietary OS, running on a motorola 68010.
The problem I have for the moment is related to initial values for
variables.
If the initial value is a pointer, this pointer has to be updated at
run-time, since we don't know the correct PIC address at compile-time.
The solution I would like to implement is:
When an initial value is found, and it is a pointer, I want to put
a label for the pointer-address, and then put the initial value for
the pointer.
Then I want to switch to a special section and put a pointer to the
pointer to be updated.
Then, at run-time, the special section would be read, and the
pointers pointed to, will be updated to the proper PIC address.
Too complicated? Perhaps an example explains it better:
This simple c-code:
struct tabtype {int i; char *c;};
static struct tabtype a_table[] =
{
{1, "Stina"},
{2, "Karin"}
};
Generates this assembler-code:
section 5
LC0:
dc.b 'Stina',0
LC1:
dc.b 'Karin',0
a_table:
dc.l 1
dc.l LC0
dc.l 2
dc.l LC1
This is what I would like it to generate:
section 5
LC0:
dc.b 'Stina',0
LC1:
dc.b 'Karin',0
a_table:
dc.l 1
PIC0: dc.l LC0
section 6
dc.l PIC0
section 5
dc.l 2
PIC1: dc.l LC1
section6
dc.l PIC1
Comments:
"section 5" is the data section
"section 6" is the new special section
Any ideas where to modify?
Thanks,
/Jan
=======================================================================
Jan Bengtsson
Ericsson Telecom AB Email: etxjben@iog.ericsson.se
Tellusborsgv. 83-87 Memo: eri.etx.etxjben
126 25 Stockholm Phone: +46 8 719 5199
FAX: +46 8 719 6482
=======================================================================
Technical Details
Message-ID:
<etxjben.726930006@garbo300>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ericom!garbo300!etxjbenShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,526c145902e12f30,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-01-13 05:25:44 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ericom!garbo300!etxjben From: etxjben@garbo300.ericsson.se (Jan Bengtsson) Subject: How to generate PIC code for initial data? Message-ID: <etxjben.726930006@garbo300> Summary: How to generate PIC code for initial data, if it is a pointer. Keywords: PIC Sender: news@ericsson.se Nntp-Posting-Host: garbo300.ericsson.se Organization: Ericsson Distribution: gnu.gcc.help Date: Wed, 13 Jan 1993 13:00:06 GMT Lines: 75