Skip to content

Commit 2ece847

Browse files
author
Luca Toniolo
committed
build: Filter undefined symbols from rtapi module version scripts
rtapi_app.h unconditionally declares EXPORT_SYMBOL for both rtapi_app_main and rtapi_app_exit, so every module's .rtapi_export section lists both names even when the module only implements rtapi_app_main (e.g. hal/components/enum.c). LLD 17+ defaults to --no-undefined-version (LLVM D135402) and then refuses to link: ld.lld: error: version script assignment of 'global' to symbol 'rtapi_app_exit' failed: symbol not defined Drop the -j .rtapi_export filter from the objdump call so the same pass sees the full symbol table, and extend the awk script to track both the exported names and the actually-defined symbols, emitting only their intersection. GNU ld behaviour is unchanged (the new global list is a strict subset of the old one) and LLD is happy. Fixes #3191.
1 parent 568354c commit 2ece847

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,8 @@ modules: $(patsubst %.o,../rtlib/%.so,$(obj-m))
12541254
../rtlib/%.so:
12551255
$(ECHO) Linking $@
12561256
$(Q)ld -d -r -o objects/$*.tmp $^
1257-
$(Q)objdump -w -j .rtapi_export -t objects/$*.tmp \
1258-
| awk 'BEGIN{print "{ global :"} /rtapi_exported_/{printf("%s;\n", substr($$6,16))} END{print "local : * ; };"}' \
1257+
$(Q)objdump -w -t objects/$*.tmp \
1258+
| awk 'BEGIN{print "{ global :"} /\.rtapi_export/ && /rtapi_exported_/{e[substr($$NF,16)]=1; next} /\*UND\*/{next} {d[$$NF]=1} END{for(s in e) if(s in d) printf("%s;\n",s); print "local : * ; };"}' \
12591259
> objects/$*.ver
12601260
$(Q)$(CC) -shared -Bsymbolic -Wl,--version-script,objects/$*.ver -o $@ $^ -lm $(LDFLAGS)
12611261
$(Q)chmod -x $@

src/Makefile.modinc.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ $(foreach mod,$(patsubst %.o,%,$(obj-m)),\
120120
%.so:
121121
$(ECHO) Linking $@
122122
$(Q)ld -d -r -o $*.tmp $^
123-
$(Q)objdump -w -j .rtapi_export -t $*.tmp \
124-
| awk 'BEGIN{print "{ global :"} /rtapi_exported_/{printf("%s;\n", substr($$6,16))} END{print "local : * ; };"}' \
123+
$(Q)objdump -w -t $*.tmp \
124+
| awk 'BEGIN{print "{ global :"} /\.rtapi_export/ && /rtapi_exported_/{e[substr($$NF,16)]=1; next} /\*UND\*/{next} {d[$$NF]=1} END{for(s in e) if(s in d) printf("%s;\n",s); print "local : * ; };"}' \
125125
> $*.ver
126126
$(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -Wl,--version-script,$*.ver -o $@ $^ -lm $(EXTRA_LDFLAGS)
127127
$(Q)chmod -x $@

0 commit comments

Comments
 (0)