Bug 214464

Summary: gcc should compile crtbeginT.o w/ fPIC on Intel 64 (x86_64)
Product: Red Hat Enterprise Linux 4 Reporter: Jeff Sullivan <jeff.sullivan>
Component: gcc4Assignee: Jakub Jelinek <jakub>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-11-07 20:44:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jeff Sullivan 2006-11-07 19:11:27 UTC
Description of problem:

gcc should compile crtbeginT.o w/ fPIC on Intel 64 to avoid following problem -
 seen when using icc -fast to create a shared library (that example below).

This works:

$ gcc -static -fpic scale.c -o libscale.so -shared -m32

This fails:

$ gcc -static -fpic scale.c -o libscale.so -shared -m64
/usr/bin/ld: /opt/spdtools/compiler/ia32e/gcc-4.1.0/lib/gcc/x86_64-unknown-
linux-gnu/4.1.0/crtbeginT.o: relocation R_X86_64_32 can not be used when 
making a shared object; recompile with -fPIC
/opt/spdtools/compiler/ia32e/gcc-4.1.0/lib/gcc/x86_64-unknown-linux-
gnu/4.1.0/crtbeginT.o: could not read symbols: Bad value
collect2: ld returned 1 exit status


Version-Release number of selected component (if applicable):

$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.1.0/configure --
prefix=/opt/spdtools/compiler/ia32e/gcc-4.1.0
Thread model: posix
gcc version 4.1.0


How reproducible:

I was able to reproduce this problem with gcc 3.2.3 and 4.0.0 on x86_64. I did 
not see the problem using gcc 4.1.0.  

Steps to Reproduce:

1. Copy test case (below) to an x86_64 machine
2. Compile the test case: gcc -static -fpic scale.c -o libscale.so -shared -m64
3. Look for error message
  
Actual results:

// Fails with -m64

% gcc40 -static -fpic scale.c -o libscale.so -shared -m64
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.1.0/crtbeginT.o: relocation 
R_X86_64_32 against `__deregister_frame_info' can not be used when making a 
shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/4.1.0/crtbeginT.o: could not read symbols: Bad
value
collect2: ld returned 1 exit status 

Expected results:

// Works with -m32
% gcc40 -static -fpic scale.c -o libscale.so -shared -m32
%

Additional info:

Here's the test case:

% cat scale.c
#include <stdio.h>

int scale(int val)
{
  const int scalefactor = 999;
  int i= scalefactor * val;
  printf("scalefactor=%i. val=%i. i=%i \n", scalefactor, val, i);
  return i;
}

Comment 1 Jakub Jelinek 2006-11-07 20:44:26 UTC

*** This bug has been marked as a duplicate of 214465 ***