Article View: gnu.gcc.help
Article #53004sun pic from gcc?
From: Kiran Shah
Date: Fri, 03 Apr 1992 05:00
Date: Fri, 03 Apr 1992 05:00
82 lines
2823 bytes
2823 bytes
Dear GNU:
We are so-far satisfied users of 'gcc' version 1.39 on our Sun
SPARC/2 running SunOS 4.1.1. We recently began to investigate
creating our own shared libraries. To do so, all object code
must be PIC, or "position independent code". In PIC, all
references to external data objects are generated as dereferences
of entries in a "Global Offset Table". At run time, the dynamic
linker resolves the references in the GOT for each program. Since
the code references the GOT, it doesn't need to change, so the
code is shareable between processes. The Sun C compiler provides
the '-pic' option, which produces such code. As far as we can
tell, this is unsupported in 'gcc'. Does GNU provide any tools
for creating PIC, or shared libraries? If so, please direct us
to the appropriate sources. Below is a small example illustrating
the difference between 'gcc' and 'cc -pic' for a simple program.
Thanks very much!
-------------------------seterr.c---------------------
#include <errno.h>
main()
{
errno = EACCES;
}
---------------- 'gcc -S' output ---------------------
gcc_compiled.:
.text
.align 4
.global _main
.proc 1
_main:
!#PROLOGUE# 0
save %sp,-80,%sp
!#PROLOGUE# 1
mov 13,%o0
sethi %hi(_errno),%g1
st %o0,[%g1+%lo(_errno)]
L1:
ret
restore
------------- 'cc -pic' output -------------------------
LL0:
.seg "data"
.seg "text"
.proc 04
.global _main
_main:
!#PROLOGUE# 0
sethi %hi(LF13),%g1
add %g1,%lo(LF13),%g1
save %sp,%g1,%sp
1:
call 2f
sethi %hi(__GLOBAL_OFFSET_TABLE_ - (1b-.)), %l7
2:
or %l7, %lo(__GLOBAL_OFFSET_TABLE_ - (1b-.)), %l7
add %l7, %o7, %l7
!#PROLOGUE# 1
ld [%l7+_errno],%o0
mov 0xd,%o1
st %o1,[%o0]
LE13:
ret
restore
LF13 = -64
LP13 = 64
LST13 = 64
LT13 = 64
.seg "data"
----------------------------------------------------------------
+-----------------------------------------------------------------+
| Kiran Shah | IDD Information Services |
| kiran.shah@channel1.com | 100 Fifth Avenue, Waltham, MA 02154 |
+-----------------------------------------------------------------+
---
~ DeLuxe} 1.12 #642sa ~
--
Channel 1 (R) Cambridge, MA
Technical Details
Message-ID:
<1992Apr3.700.14098@channel1>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!channel1.COM!kiran.shahShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,655d8d7bbd38afd1,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-04-02 21:00:00 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!channel1.COM!kiran.shah From: kiran.shah@channel1.COM (Kiran Shah) Subject: sun pic from gcc? Message-ID: <1992Apr3.700.14098@channel1> Sender: daemon@cis.ohio-state.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 3 Apr 1992 05:00:00 GMT Lines: 83