🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #16

gcc 2.2.2 -fpic on sun386i generates illegal assembly code

#16
From: Thomas Tornblom
Date: Thu, 29 Oct 1992 12:04
65 lines
1739 bytes
Compiling the following simple file makes suns as complain:
---------
foo()
{
    (void) bar(42);
}
---------

gcc -fpic -S -O2 (-O2 doesn't matter, the code just gets shorter)
produces the following illegal assembly code:
----
	.file	"foo.c"
	.version	"GNU C 2.2.2"
	.optim
gcc2_compiled.:
.text
	.align 4
.globl foo
foo:
	pushl %ebp
	movl %esp,%ebp
	pushl %ebx
	call .L2
.L2:
	popl %ebx
	addl $_GLOBAL_OFFSET_TABLE_+[.-.L2],%ebx
	pushl $42
	call bar@PLT				<= illegal character
	movl -4(%ebp),%ebx
	leave
	ret
---------
cc -pic -S -O produces the following code:
---------
	.file	"foo.c"
	.version	"sun386-1.0"
	.optim
.LL0:
        .data
	.text
	.globl	foo
foo:
	pushl	%ebp
	movl	%esp,%ebp
	pushl	%ebx
	call	.+5
	pop	%ebx
	add	$_globtb_offset,%ebx
	pushl	$42
	call	bar,%eax			<= this is ok
	popl	%ecx
/ASMQ
	movl	-4(%ebp),%ebx
/ASMEND0
	leave	
	ret	
/FUNCEND

        .data
	.text
--
Real life:      Thomas Tornblom           Email:  Thomas.Tornblom@Nexus.Comm.SE
Snail mail:     Communicator Nexus AB     Phone:  +46 18 171814
                Box 857                   Fax:    +46 18 696516
                S - 751 08 Uppsala, Sweden
Technical Details
Message-ID: <THOMAS.TORNBLOM.92Oct29130414@beck.nexus.comm.se>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!nexus.comm.se!Thomas.Tornblom

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!nexus.comm.se!Thomas.Tornblom
From: Thomas.Tornblom@nexus.comm.se (Thomas Tornblom)
Newsgroups: gnu.gcc.bug
Subject: gcc 2.2.2 -fpic on sun386i generates illegal assembly code
Message-ID: <THOMAS.TORNBLOM.92Oct29130414@beck.nexus.comm.se>
Date: 29 Oct 92 12:04:14 GMT
Article-I.D.: beck.THOMAS.TORNBLOM.92Oct29130414
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: Communicator Nexus AB
Lines: 65
Approved: bug-gcc@prep.ai.mit.edu