http://sourceware.org/bugzilla/show_bug.cgi?id=14426

             Bug #: 14426
           Summary: add --ignore-unresolved-symbol from NetBSD
           Product: binutils
           Version: 2.23 (HEAD)
               URL: http://mail-index.netbsd.org/source-changes/2008/04/03
                    /msg004439.html
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassig...@sourceware.org
        ReportedBy: bugme...@mailinator.com
    Classification: Unclassified


Created attachment 6563
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6563
add --ignore-unresolved-symbol

Sometimes it's useful to leave a symbol undefined even if -z defs is used. The
symbol can still be resolved by runtime linker.

Here's an example:

// foo.c
#include <spawn.h>
#include <stdlib.h>
#include <string.h>

extern char **environ;

void foo(void) {
  char *spawn_argv[] = { "/usr/bin/printenv", NULL };
  char *spawn_envp[] = { (char *)malloc(strlen(environ[0])), NULL };

  strcpy(spawn_envp[0], environ[0]);
  posix_spawnp(NULL, spawn_argv[0], NULL, NULL, spawn_argv, spawn_envp);
}

$ gcc47 -shared -Wl,-z,defs -o foo.so foo.c -fPIC
/tmp//cc2QDr9J.o: In function `foo':
foo.c:(.text+0x1e): undefined reference to `environ'
foo.c:(.text+0x47): undefined reference to `environ'
collect2: error: ld returned 1 exit status
$ gcc47 -shared -Wl,-z,defs -o foo.so foo.c -fPIC
-Wl,--ignore-unresolved-symbol,environ
$

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to