DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.59k stars 552 forks source link

COMPILATION ERROR: Inlining clone.c:make_clone3_syscall -> multiply defined symbols #6627

Closed xdje42 closed 5 months ago

xdje42 commented 5 months ago

Describe the bug

This is a general bug, there are several places where labels are used in embedded asms. This bug concerns the immediate issue of compilation failures when clone.c:make_clone3_syscall is inlined, causing the label "parent" to be multiply defined.

To Reproduce

$ clang --version
Debian clang version 16.0.6 (16)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang -I ../dynamorio/core/drlibc -I ../dynamorio/core/lib -I ../dynamorio/suite/tests -I . -I include \
  -O1 -c ../dynamorio/suite/tests/linux/clone.c -o clone.o

-->

In file included from ../dynamorio/suite/tests/linux/clone.c:50:
In file included from ../dynamorio/suite/tests/tools.h:46:
../dynamorio/core/drlibc/drlibc.h:147:43: warning: declaration of
      'struct stat64' will not be visible outside of this function
      [-Wvisibility]
dr_stat_syscall(const char *fname, struct stat64 *st);
                                          ^
../dynamorio/suite/tests/linux/clone.c:253:32: error: symbol 'parent' is
      already defined
                 "call *%%rdx\n\t"
                               ^
<inline asm>:9:2: note: instantiated into assembly here
        parent:
        ^
../dynamorio/suite/tests/linux/clone.c:253:32: error: symbol 'parent' is
      already defined
                 "call *%%rdx\n\t"
                               ^
<inline asm>:9:2: note: instantiated into assembly here
        parent:
        ^
../dynamorio/suite/tests/linux/clone.c:253:32: error: symbol 'parent' is
      already defined
                 "call *%%rdx\n\t"
                               ^
<inline asm>:9:2: note: instantiated into assembly here
        parent:
        ^
../dynamorio/suite/tests/linux/clone.c:253:32: error: symbol 'parent' is
      already defined
                 "call *%%rdx\n\t"
                               ^
<inline asm>:9:2: note: instantiated into assembly here
        parent:
        ^
1 warning and 4 errors generated.

Versions

xdje42 commented 5 months ago

The fix is to use "local labels". Ref: https://sourceware.org/binutils/docs-2.42/as/Symbol-Names.html