bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/30138] New: localize symbol is broken when using x64 versi


From: alexeysamson at yandex dot ru
Subject: [Bug binutils/30138] New: localize symbol is broken when using x64 version of mingw
Date: Sun, 19 Feb 2023 13:37:25 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30138

            Bug ID: 30138
           Summary: localize symbol is broken when using x64 version of
                    mingw
           Product: binutils
           Version: 2.41 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: alexeysamson at yandex dot ru
  Target Milestone: ---

I compile and linking my programm with mingw x64.
gcc version 12.2.0 (x86_64-win32-seh-rev2, Built by MinGW-W64 project)

I have two files:

                                  foo_var.c:
int global_var = 1;


                                foo_print.c:
#include <stdio.h>

extern int global_var;

void print_foo(void)
{
    printf("print_foo = %d\n", global_var);
}

that compile and link into foo.o and localize global_var:

gcc -c foo.c foo_print.c
ld -r -o foo.o foo_print.o foo_var.o
objcopy -L global_var foo.o
And two files

                                  bar_var.c:
int global_var = 2;

                                bar_print.c:

#include <stdio.h>

extern int global_var;

void print_bar(void)
{
    printf("print_bar = %d\n", global_var);
}

compile and link into bar.o and localize global_var too:

gcc -c bar.c bar_print.c
ld -r -o bar.o bar_print.o bar_var.o
objcopy -L global_var bar.o

also I have main, where I call print_foo and print_bar

                                   main.c:

void print_foo(void);
void print_bar(void);

int main(int argc, char const *argv[])
{
    print_foo();
    print_bar();

    return 0;
}

When I compile and link all together:

gcc -c main.c
gcc main.o foo.o bar.o
and run a.exe 

I get this
print_foo = 1
print_bar = 1

instead of this
print_foo = 1
print_bar = 2

Seems like localize symbol is broken somehow when using x64 version of mingw.
In x32 this example works fine, but i cant fit my programm in 2 gb ram.
I managed to do this example on linux too, and its work fine even with x64.
Mb its caused dy this fix
https://gcc.gnu.org/legacy-ml/gcc-patches/2013-03/msg00858.html.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]