bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/14426] New: add --ignore-unresolved-symbol from NetBSD


From: bugmenot at mailinator dot com
Subject: [Bug ld/14426] New: add --ignore-unresolved-symbol from NetBSD
Date: Wed, 01 Aug 2012 12:56:49 +0000

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: address@hidden
        ReportedBy: address@hidden
    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.



reply via email to

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