add support for hosts that have custom symbol prefixes
some architectures, like Blackfin, have a prefix added to all symbols (in our case it's historical baggage)
while normally packages shouldnt care, when code starts mixing assembler with C (like symbol versioning), you need to dip down into the inner details. find attached a patch which queries gcc for the prefix (all gcc toolchains have a builtin define of __USER_LABEL_PREFIX__) and then automatically has asm() constructs utilize this
since most targets define __USER_LABEL_PREFIX__ to nothing, hopefully this shouldnt cause any problems :)
-mike
configure.in +11 -0
@@ -34,6 +34,7 @@ fi AC_PROG_CC +AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_DISABLE_STATIC
@@ -104,6 +105,16 @@ else AC_MSG_RESULT(no) fi AM_CONDITIONAL(VERSIONED_SYMBOLS, test x$versioned = xyes) + +dnl See if toolchain has a custom prefix for symbols ... +AC_MSG_CHECKING(for custom symbol prefixes) +SYMBOL_PREFIX=` \ + echo "PREFIX=__USER_LABEL_PREFIX__" \ + | ${CPP-${CC-gcc} -E} - 2>&1 \ + | ${EGREP-grep} "^PREFIX=" \ + | ${SED-sed} "s:^PREFIX=::"` +AC_DEFINE_UNQUOTED([__SYMBOL_PREFIX], "$SYMBOL_PREFIX", [Toolchain Symbol Prefix]) +AC_MSG_RESULT($SYMBOL_PREFIX) dnl Check for debug... AC_MSG_CHECKING(for debug)
include/alsa-symbols.h +22 -14
@@ -22,6 +22,14 @@#ifndef __ALSA_SYMBOLS_H#define __ALSA_SYMBOLS_H +#ifdef __USER_LABEL_PREFIX__ +# define __SYMBOL_PREFIX __USER_LABEL_PREFIX__ +#else +# define __SYMBOL_PREFIX +#endif + +#include "local.h" +#if defined(PIC ) && defined(VERSIONED_SYMBOLS )/* might be also configurable */ #define USE_VERSIONED_SYMBOLS #endif
@@ -31,16 +39,16 @@#ifdef __powerpc64__# define symbol_version (real, name, version) \ - __asm__ (".symver " #real "," #name "@" #version); \ - __asm__ (".symver ." #real ",." #name "@" #version) + __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@" #version); \ + __asm__ (".symver ." ASM_NAME(#real) ",." ASM_NAME(#name) "@" #version)# define default_symbol_version (real, name, version) \ - __asm__ (".symver " #real "," #name "@@" #version); \ - __asm__ (".symver ." #real ",." #name "@@" #version) + __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@@" #version); \ + __asm__ (".symver ." ASM_NAME(#real) ",." ASM_NAME(#name) "@@" #version)#else # define symbol_version (real, name, version) \ - __asm__ (".symver " #real "," #name "@" #version) + __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@" #version)# define default_symbol_version (real, name, version) \ - __asm__ (".symver " #real "," #name "@@" #version) + __asm__ (".symver " ASM_NAME(#real) "," ASM_NAME(#name) "@@" #version)#endif #ifdef USE_VERSIONED_SYMBOLS
@@ -52,19 +60,19 @@#define use_symbol_version (real, name, version)/* nothing */ #ifdef __powerpc64__#define use_default_symbol_version (real, name, version) \ - __asm__ (".weak " #name); \ - __asm__ (".weak ." #name); \ - __asm__ (".set " #name "," #real); \ - __asm__ (".set ." #name ",." #real) + __asm__ (".weak " ASM_NAME(#name)); \ + __asm__ (".weak ." ASM_NAME(#name)); \ + __asm__ (".set " ASM_NAME(#name) "," ASM_NAME(#real)); \ + __asm__ (".set ." ASM_NAME(#name) ",." ASM_NAME(#real))#else #if defined(__alpha__) || defined(__mips__)#define use_default_symbol_version (real, name, version) \ - __asm__ (".weak " #name); \ - __asm__ (#name " = " #real) + __asm__ (".weak " ASM_NAME(#name)); \ + __asm__ (ASM_NAME(#name) " = " ASM_NAME(#real))#else #define use_default_symbol_version (real, name, version) \ - __asm__ (".weak " #name); \ - __asm__ (".set " #name "," #real) + __asm__ (".weak " ASM_NAME(#name)); \ + __asm__ (".set " ASM_NAME(#name) "," ASM_NAME(#real))#endif #endif #endif
include/local.h +8 -5
@@ -192,6 +192,9 @@ extern snd_lib_error_handler_t snd_err_m/* When a reference to SYMBOL is encountered, the linker will emit a warning message MSG. */ + +#define ASM_NAME (name) __SYMBOL_PREFIX name +#ifdef HAVE_GNU_LD # ifdef HAVE_ELF
@@ -210,19 +213,19 @@ extern snd_lib_error_handler_t snd_err_msection attributes on what looks like a comment to the assembler. */ # ifdef HAVE_SECTION_QUOTES # define link_warning (symbol, msg) \ - __make_section_unallocated (".gnu.warning." #symbol) \ + __make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \ static const char __evoke_link_warning_##symbol[] \ - __attribute__ ((section (".gnu.warning." #symbol "\"\n\t#\""))) = msg; + __attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\"\n\t#\""))) = msg;# else # define link_warning (symbol, msg) \ - __make_section_unallocated (".gnu.warning." #symbol) \ + __make_section_unallocated (".gnu.warning." ASM_NAME(#symbol)) \ static const char __evoke_link_warning_##symbol[] \ - __attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg; + __attribute__ ((section (".gnu.warning." ASM_NAME(#symbol) "\n\t#"))) = msg;# endif # else # define link_warning (symbol, msg) \ asm (".stabs \"" msg "\",30,0,0,0\n\t" \ - ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n"); + ".stabs \"" ASM_NAME(#symbol) "\",1,0,0,0\n");# endif #else /* We will never be heard; they will all die horribly. */
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
At Thu, 7 Sep 2006 20:47:00 -0400,
Quoted 4 lines · Mike Frysinger
some architectures, like Blackfin, have a prefix added to all symbols (in our case it's historical baggage)
Quoted 8 lines
while normally packages shouldnt care, when code starts mixing assembler with C (like symbol versioning), you need to dip down into the inner details. find attached a patch which queries gcc for the prefix (all gcc toolchains have a builtin define of
__USER_LABEL_PREFIX__) and then automatically hasasm()constructs utilize thissince most targets define
__USER_LABEL_PREFIX__to nothing, hopefully this shouldnt cause any problems :)
So, the current build doesn't work for such architectures with __USER_LABEL_PREFIX__? The change you did basically looks OK to me...
Quoted 4 lines
diff -r
46221e609f45include/alsa-symbols.h
include/alsa-symbols.h line 31
Quoted 10 lines
include/alsa-symbols.h +7
-0@@ -22,6 +22,14 @@#ifndef __ALSA_SYMBOLS_H#define __ALSA_SYMBOLS_H +#ifdef __USER_LABEL_PREFIX__ +# define __SYMBOL_PREFIX __USER_LABEL_PREFIX__ +#else +# define __SYMBOL_PREFIX +#endif + +#include "local.h"
This inclusion looks superfluous. This file itself is included from local.h.
Takashi
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Quoted 10 lines · Takashi Iwai
Quoted 9 lines · Mike Frysinger
some architectures, like Blackfin, have a prefix added to all symbols (in our case it's historical baggage)
while normally packages shouldnt care, when code starts mixing assembler with C (like symbol versioning), you need to dip down into the inner details. find attached a patch which queries gcc for the prefix (all gcc toolchains have a builtin define of
__USER_LABEL_PREFIX__) and then automatically hasasm()constructs utilize this
Quoted 5 lines
Quoted 2 lines
since most targets define
__USER_LABEL_PREFIX__to nothing, hopefully this shouldnt cause any problems :)So, the current build doesn't work for such architectures with
__USER_LABEL_PREFIX__?
correct ... on blackfin, __USER_LABEL_PREFIX__ is defined to _
so when you have a function foo() in C, the actual ELF symbol is _foo ... the asm() tricks to do symbol aliasing then fail as they try to manipulate the ELF symbol foo which doesnt exist
Quoted 7 lines
Quoted 7 lines
diff -r
46221e609f45include/alsa-symbols.hinclude/alsa-symbols.h +0
-0@@ -22,6 +22,14 @@#ifndef __ALSA_SYMBOLS_H#define __ALSA_SYMBOLS_H
Quoted 10 lines
include/alsa-symbols.h line 31
Quoted 7 lines
include/alsa-symbols.h +7
-0+#ifdef __USER_LABEL_PREFIX__ +# define __SYMBOL_PREFIX __USER_LABEL_PREFIX__ +#else +# define __SYMBOL_PREFIX +#endif + +#include "local.h" This inclusion looks superfluous. This file itself is included from
local.h.
this is my first time hacking on ALSA code so i'll of course defer to anyone with more experience :) i added this as a sanity check rather than digging through the include paths in the headers
if it isnt needed then simply disregard that hunk :) -mike
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
At Fri, 8 Sep 2006 16:18:55 -0400,
Quoted 42 lines · Mike Frysinger
Quoted 10 lines · Takashi Iwai
Quoted 9 lines · Mike Frysinger
some architectures, like Blackfin, have a prefix added to all symbols (in our case it's historical baggage)
while normally packages shouldnt care, when code starts mixing assembler with C (like symbol versioning), you need to dip down into the inner details. find attached a patch which queries gcc for the prefix (all gcc toolchains have a builtin define of
__USER_LABEL_PREFIX__) and then automatically hasasm()constructs utilize thisQuoted 5 lines
Quoted 2 lines
since most targets define
__USER_LABEL_PREFIX__to nothing, hopefully this shouldnt cause any problems :)So, the current build doesn't work for such architectures with
__USER_LABEL_PREFIX__?correct ... on blackfin,
__USER_LABEL_PREFIX__is defined to _so when you have a function
foo()in C, the actual ELF symbol is_foo... theasm()tricks to do symbol aliasing then fail as they try to manipulate the ELF symbol foo which doesnt existQuoted 7 lines
Quoted 7 lines
diff -r
46221e609f45include/alsa-symbols.hinclude/alsa-symbols.h +0
-0@@ -22,6 +22,14 @@#ifndef __ALSA_SYMBOLS_H#define __ALSA_SYMBOLS_HQuoted 10 lines
include/alsa-symbols.h line 31
Quoted 7 lines
include/alsa-symbols.h +7
-0+#ifdef __USER_LABEL_PREFIX__ +# define __SYMBOL_PREFIX __USER_LABEL_PREFIX__ +#else +# define __SYMBOL_PREFIX +#endif + +#include "local.h" This inclusion looks superfluous. This file itself is included from
local.h.
Quoted 5 lines
this is my first time hacking on ALSA code so i'll of course defer to anyone with more experience :) i added this as a sanity check rather than digging through the include paths in the headers
if it isnt needed then simply disregard that hunk :)
I committed the patch to ALSA HG tree now.
Give it a try later.
thanks,
Takashi
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV