Hello, all

Can gatekeeper review the attached patch for bug #713
(https://bugs.open64.net/show_bug.cgi?id=713) please? Thank you.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Bug #713 can be reproduced with the following test-case (also attached
to bug #713's bug report):

#include <stdio.h>

typedef struct _GFloppy {
    char *device;
} GFloppy;

static GFloppy floppy;

typedef struct _GDevice {
    void *ptr;
} GDevice;

int main(int argc, char *argv[])
{
    static GDevice dev = { &(floppy.device) };

    printf("%d\n", *(int*)(dev.ptr));
    return 0;
}

This bug only happens when -Ofast is specified. With IPA, two .I files
are generated: symtab.I and 1.I (which contains code of main
function). The static symbol `floppy' is merged into global symbol
table (symtab.I/G) and emitted into symtab.s. It is not exported
because it is a local symbol. On the other hand, when generating the
initialization code for `dev' from INITO table during compiling the
main function, code emission generates references to `floppy'
directly. This caused the linking problem since `floppy' is not
exported. The fix is, instead of generating references to local
symbols directly when IPA is enabled, generate references using the
section start + offset.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Feng Zhou

Attachment: bug713_v2.patch
Description: Binary data

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to