This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 164810 - g++ generates bad assembly with -masm=intel -fPIC
g++ generates bad assembly with -masm=intel -fPIC
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On: 162585
Blocks: 156322
  Show dependency treegraph
Reported: 2005-08-01 12:07 EDT by Elena Zannoni
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version: RHBA-2005-677
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-10-05 07:18:51 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Elena Zannoni 2005-08-01 12:07:53 EDT
+++ This bug was initially created as a clone of Bug #162585 +++

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050323
Firefox/1.0.2 Fedora/1.0.2-1.3.1

Description of problem:
g++ -masm=intel -fPIC -g -Wall -S
g++-3.4.3 -masm=intel -fPIC -g -Wall main.s -c
g++-3.4.3 -o testcase main.o
Segmentation fault

Same when using g++ instead of g++-3.4.3 for the final steps.
Plain g++-3.4.3 -masm=intel -fPIC -g -Wall -S generates
correct assembly.

The problem is:

~/c++/g++.bugs/bug23>grep -B3 OFFSET main.s | head -n 4
        call    .L4
        pop     %ebx
        add     %ebx, _GLOBAL_OFFSET_TABLE_+(.-.L4)

This is broken, it results in assembly without offset,
trying to access low memory addresses.

Correct is:
        call    __i686.get_pc_thunk.bx
        add     %ebx, OFFSET FLAT:_GLOBAL_OFFSET_TABLE_

which is generated by plain g++-3.4.3, or if you must,

        call    .L4
        pop     %ebx
        add     %ebx, OFFSET _GLOBAL_OFFSET_TABLE_+(.-.L4)

In other words: 'OFFSET' is missing.

For example:
        call    .L4
        pop     %ebx
        add     %ebx, _GLOBAL_OFFSET_TABLE_+(.-.L4)

The test case source is as follows:

struct A { virtual ~A() { } };
int main() { A a; }

Carlo Wood


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

How reproducible:

Steps to Reproduce:
1. Create a test case file '' with the following contents:

struct A { virtual ~A() { } };
int main() { A a; }

2. Compile it into an assembly file 'main.s' using both
   -masm=intel and -fPIC

g++ -masm=intel -fPIC -g -Wall -S

3. Examine the how the PIC pointer (ebx) is calculated:

add     %ebx, _GLOBAL_OFFSET_TABLE_+(.-.L4)

4. Note that the keyword OFFSET is missing.

Actual Results:  I am getting tired of repeating myself.

Expected Results:  The OFFSET should have been there, see 'description'.

Additional info:

I discussed this in detail with the gcc developers,
I am involved with g++ myself too (plain, not redhats version).
I wish you guys didn't make changes to the compiler :/
Comment 3 Red Hat Bugzilla 2005-10-05 07:18:51 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

Note You need to log in before you can comment on or make changes to this bug.