bug-binutils
[Top][All Lists]
Advanced

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

[Bug gas/16858] weak external reference has wrong value


From: bernd.edlinger at hotmail dot de
Subject: [Bug gas/16858] weak external reference has wrong value
Date: Mon, 21 Apr 2014 16:21:16 +0000

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

--- Comment #2 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 7557
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7557&action=edit
Assembler-Source where the bug was discovered

with objdump -d -r crtbegin.o we have wrong code:

  f3:   83 ec 04                sub    $0x4,%esp
  f6:   85 c0                   test   %eax,%eax
  f8:   ba f0 ff ff ff          mov    $0xfffffff0,%edx
                        f9: dir32       ___deregister_frame_info
  fd:   74 16                   je     115 <___gcc_deregister_frame+0x35>


but the cygming-crtbegin.s looks correct:

LVL17:
        .loc 1 158 0
        testl   %eax, %eax
        .loc 1 162 0
        movl    $___deregister_frame_info, %edx
        .loc 1 158 0
        je      L27


whenever there is a weak definition the reference is actually minus
the offset of the previous weak definition. Everything is OK if that was
at offset zero.

test case:

$ cat test.c
#include <stdio.h>

extern void test() __attribute__((weak));

int main()
{
  printf("hello\n");
  test();
  return 0;
}

__attribute__((weak))
void test()
{
  printf("weak\n");
}

$ cat test1.c
#include <stdio.h>

void test()
{
  printf("strong\n");
}


$ gcc -o test test.c test1.c
$ ./test
hello
Segmentation fault (core dumped)

-- 
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]