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: Tue, 29 Apr 2014 14:37:12 +0000

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

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #10 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Hi, I installed your patch on a 2.24 binutils, and
I am still having trouble with the following example:
(on i686-cygwin-32)

$ gcc test0.c
$ ./a
hello
weak
hello
weak
hello
weak
hello
weak
hello
weak
...

$ gcc test0.c test1.c
$ ./a
hello
strong
Segmentation fault (Speicherabzug geschrieben)


the first direct call to test is OK now, but the second
using pointer (weak reference!) still does not work.
I am afraid the second use-case is what GCC will use.

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

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

int main()
{
  void (*f)();
  printf("hello\n");
  test();
  f = &test;
  if (f != NULL)
    (*f)();
  else
    printf("no weak\n");
  return 0;
}

#if 1
//__attribute__((weak,section("test1")))
void test()
{
  printf("weak\n");
}
#endif

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

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

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