build: use a different method to expose symbols

.. the old method doesn't work on aarch64 and apparently caused problem
with powerpc back in the day.  The new method has been tested to work on
amd64 and aarch64 and is expected to be more portable: it is the normal
method used to select the symbols visible in a shared library.

(I don't have a powerpc to test with)

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
Jeff Epler 2015-07-09 02:04:52 +00:00
parent 00aff4a53e
commit e4b94a5df9
2 changed files with 5 additions and 6 deletions

View file

@ -962,9 +962,8 @@ modules: $(patsubst %.o,../rtlib/%.so,$(obj-m))
../rtlib/%.so: ../rtlib/%.so:
$(ECHO) Linking $@ $(ECHO) Linking $@
$(Q)ld -d -r -o objects/$*.tmp $^ $(Q)ld -d -r -o objects/$*.tmp $^
@if ! $(IS_POWERPC); then objcopy -j .rtapi_export -O binary objects/$*.tmp objects/$*.exp; fi $(Q)(echo '{ global : '; objcopy -j .rtapi_export -O binary objects/$*.tmp /dev/stdout | tr -s '\0' | xargs -r0 printf '%s;\n' | grep .; echo 'local : * ; };') > objects/$*.ver
@if ! $(IS_POWERPC); then objcopy -G __x86.get_pc_thunk.bx -G __i686.get_pc_thunk.bx `xargs -r0n1 echo -G < objects/$*.exp | grep -ve '^-G $$' | sort -u` objects/$*.tmp; fi $(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -Wl,--version-script,objects/$*.ver -o $@ $^ -lm
$(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -o $@ objects/$*.tmp -lm
RTFLAGS += -fno-strict-aliasing -fwrapv RTFLAGS += -fno-strict-aliasing -fwrapv

View file

@ -119,9 +119,9 @@ IS_POWERPC = test `uname -m` = ppc -o `uname -m` = ppc64
%.so: %.so:
$(ECHO) Linking $@ $(ECHO) Linking $@
$(Q)ld -d -r -o $*.tmp $^ $(Q)ld -d -r -o $*.tmp $^
$(Q)if ! $(IS_POWERPC); then objcopy -j .rtapi_export -O binary $*.tmp $*.exp; fi $(Q)(echo '{ global : '; objcopy -j .rtapi_export -O binary $*.tmp /dev/stdout | tr -s '\0' | xargs -r0 printf '%s;\n' | grep .; echo 'local : * ; };') > $*.ver
$(Q)if ! $(IS_POWERPC); then objcopy -G __x86.get_pc_thunk.bx -G __i686.get_pc_thunk.bx `xargs -r0n1 echo -G < $*.exp | grep -ve '^-G $$' | sort -u` $*.tmp; fi $(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -Wl,--version-script,$*.ver -o $@ $^ -lm
$(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -o $@ $*.tmp -lm $(Q)ld -d -r -o $*.tmp $^
endif endif
ifeq ($(BUILDSYS),normal) ifeq ($(BUILDSYS),normal)