This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Linker magic for aliases an external symbol... how to?


Hi.

I'm packaging a daemon (a Tacacs+ proxy for SSSD authentication, if anyone is interested) and using the libtac library.

I'm using an external packaging of libtac (as a .so) which was compiled with -DTACDEBUG_AT_RUNTIME=1 which had the net effect of causing the tracing macro TACDEBUG() to expand to:

#define TACDEBUG(level, format, ...) \
do { if (tac_debug_enable) logmsg(level, format, ## __VA_ARGS__); } while (0)

problem is, the daemon doesn't provide the logmsg() function... but it does link to libc and hence provides syslog()... And yes, "level" corresponds to LOG_xxxx in <syslog.h> in the sources of the library. And no, I can't recompile or otherwise modify libtac.so I need to use it as is.

I've tried several different ways to specify at either compile time or link time that I want logmsg to be an alias to syslog().

I've tried in main.c:

void logmsg(int, const char *, ...)    asm("syslog");

and:

void logmsg(int, const char *, ...) __attribute__ ((weak, alias ("syslog")));

as well as various link-time options like:

-Wl,--defsym=logmsg=syslog

as well as:

-Wl,-Map=ld.map

where ld.map contains:

SECTIONS {
  .text :
  {
      logmsg = syslog;

  }
}

I looked around on google, codebase, stackoverflow, etc. and couldn't find a solution to this problem (external library [libtac] referencing external symbol (logmsg) that I want to alias to an entry point (syslog) in another library, in this case libc).

With all of the options that gcc and ld provide, I was sure I'd be able to do this but now it's looking like I'll have to use objcopy to do some --redefine-sym magic... but I'm not even sure I can do that since libtac is a shared-object library and I don't want to rewrite that...

Seems there's no good solution that I can find. Can someone please tell me the correct way to resolve (no pun intended) this dilemma?

Thanks,

-Philip


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]