Hi
There appears to be some bugs in LLD's handling of the '--wrap' option that
results in unexpected
"undefined symbols" in the output.
I've broken this report into { 1. Issues; 2. Reproduction; 3. Reproduction
Tests; 4: Side Observations }.
Please can somebody take a look at {1,2,3} to confirm if these are genuine
issues?
Many Thanks,
Martin
1) Issues:
==========
1.1) Using '--wrap x' results in undefined references to 'x' even when
'__real_x' isn't used inthe source code.
2) Reproduction
===============
2.1) Source setup
-----------------
+--------------------+------+----------+--------------------------------+
| Symbol x | Used | Wrapped? | Expect ...? |
| | | | x | __wrap_x | __real_x |
+--------------------+------+----------+----------+----------+----------+
| bar_fn_not_wrapped | Y | N | Y | N | N |
| bar_fn_wrapped | Y | Y | N | Y | N |
| gettimeofday | Y | Y | N | Y | N |
| sigaction | N | Y | N | N | N |
| bar_fn_other | N | Y | N | N | N |
+--------------------+------+----------+----------+----------+----------+
void bar_fn_not_wrapped(void);
void bar_fn_wrapped(void);
2.3) Test setup
---------------
+--------------------+------+----------+--------------------------------+
| Symbol x | Used | Wrapped? | Undefined symbol ...? |
| | | | x | __wrap_x | __real_x |
+--------------------+------+----------+----------+----------+----------+
| bar_fn_not_wrapped | Y | N | Y | N | N |
| bar_fn_wrapped | Y | Y | N | Y | N |
| gettimeofday | Y | Y | N | Y | N |
| sigaction | N | Y | N | N | N |
| bar_fn_other | N | Y | N | N | N |
+--------------------+------+----------+----------+----------+----------+
b) clang-9, gnu-ld
U bar_fn_not_wrapped
U __wrap_bar_fn_wrapped
U __wrap_gettimeofday
+--------------------+------+----------+--------------------------------+
| Symbol x | Used | Wrapped? | Undefined symbol ...? |
| | | | x | __wrap_x | __real_x |
+--------------------+------+----------+----------+----------+----------+
| bar_fn_not_wrapped | Y | N | Y | N | N |
| bar_fn_wrapped | Y | Y | N | Y | N |
| gettimeofday | Y | Y | N | Y | N |
| sigaction | N | Y | N | N | N |
| bar_fn_other | N | Y | N | N | N |
+--------------------+------+----------+----------+----------+----------+
c) clang-9, llvm-lld-9
U bar_fn_not_wrapped
U bar_fn_wrapped
U gettimeofday
U __real_bar_fn_wrapped
U __real_gettimeofday
w __real_sigaction
w sigaction
U __wrap_bar_fn_wrapped
U __wrap_gettimeofday
U __wrap_sigaction
+--------------------+------+----------+--------------------------------+
| Symbol x | Used | Wrapped? | Undefined symbol ...? |
| | | | x | __wrap_x | __real_x |
+--------------------+------+----------+----------+----------+----------+
| bar_fn_not_wrapped | Y | N | Y | N | N |
| bar_fn_wrapped | Y | Y | *Y* | Y | *Y* |
| gettimeofday | Y | Y | *Y* | Y | *Y* |
| sigaction | N | Y | *Y* | *Y* | *Y* |
| bar_fn_other | N | Y | N | N | N |
+--------------------+------+----------+----------+----------+----------+
d) clang-11, llvm-lld-11
U __wrap_bar_fn_wrapped
U __wrap_gettimeofday
U __wrap_sigaction
U bar_fn_not_wrapped
U bar_fn_wrapped
U gettimeofday
w sigaction
+--------------------+------+----------+--------------------------------+
| Symbol x | Used | Wrapped? | Undefined symbol ...? |
| | | | x | __wrap_x | __real_x |
+--------------------+------+----------+----------+----------+----------+
| bar_fn_not_wrapped | Y | N | Y | N | N |
| bar_fn_wrapped | Y | Y | *Y* | Y | N |
| gettimeofday | Y | Y | *Y* | Y | N |
| sigaction | N | Y | *Y* | *Y* | N |
| bar_fn_other | N | Y | N | N | N |
+--------------------+------+----------+----------+----------+----------+
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev