-
Notifications
You must be signed in to change notification settings - Fork 144
Description
Hi!
I understand that you don't seem to appreciate shared linked binaries, but in Debian we tend to at least have a preference for them.
Currently forcing tlsh_unittest to link libtlsh.so fails with this:
/usr/bin/ld: CMakeFiles/tlsh_unittest.dir/tlsh_unittest.cpp.o: in function `trendLSH_ut(char*, char*, char*, char*, int, int, char*, char*, int, bool, int, int, int, int, int, int, char*, int)':
tlsh_unittest.cpp:(.text+0x459): undefined reference to `set_input_desc(char*, char*, int, int, char*, char*, int, int, char*, InputDescr*, int)'
/usr/bin/ld: tlsh_unittest.cpp:(.text+0x4a6): undefined reference to `read_file_eval_tlsh(char*, Tlsh*, int, int, int)'
/usr/bin/ld: tlsh_unittest.cpp:(.text+0x594): undefined reference to `freeFileName(FileName*, int)'
/usr/bin/ld: tlsh_unittest.cpp:(.text+0x7da): undefined reference to `convert_special_chars(char*, char*, unsigned long, int)'
/usr/bin/ld: tlsh_unittest.cpp:(.text+0x7fb): undefined reference to `convert_special_chars(char*, char*, unsigned long, int)'
/usr/bin/ld: tlsh_unittest.cpp:(.text+0xa30): undefined reference to `convert_special_chars(char*, char*, unsigned long, int)'
/usr/bin/ld: tlsh_unittest.cpp:(.text+0xb01): undefined reference to `convert_special_chars(char*, char*, unsigned long, int)'
/usr/bin/ld: tlsh_unittest.cpp:(.text+0xba3): undefined reference to `convert_special_chars(char*, char*, unsigned long, int)'
/usr/bin/ld: CMakeFiles/tlsh_unittest.dir/tlsh_unittest.cpp.o:tlsh_unittest.cpp:(.text+0xbc4): more undefined references to `convert_special_chars(char*, char*, unsigned long, int)' follow
/usr/bin/ld: CMakeFiles/tlsh_unittest.dir/tlsh_unittest.cpp.o: in function `trendLSH_ut(char*, char*, char*, char*, int, int, char*, char*, int, bool, int, int, int, int, int, int, char*, int)':
tlsh_unittest.cpp:(.text+0xe06): undefined reference to `freeFileName(FileName*, int)'
collect2: error: ld returned 1 exit status
This is a partial result of using -fvisibility=internal (which is great!), but it also means that the tlsh_unittest binary is making use of functions that are not part of the public API nor ABI.
I made it build with this patch, that exposes the missing function in the library:
--- a/src/input_desc.cpp
+++ b/src/input_desc.cpp
@@ -153,6 +153,7 @@
return (strcmp(r1->full_fname, r2->full_fname));
}
+__attribute__ ((visibility ("default")))
int set_input_desc(char *dirname, char *listname, int listname_col, int listname_csv,
char *fname, char *digestname, int show_details, int fc_cons_option, char *splitlines, struct InputDescr *inputd, int showvers)
{
--- a/src/shared_file_functions.cpp
+++ b/src/shared_file_functions.cpp
@@ -138,6 +138,7 @@
}
}
+__attribute__ ((visibility ("default")))
const char *convert_special_chars(char *filename, char *buf, size_t bufSize, int output_json)
{
int len = strlen(filename);
@@ -182,6 +183,7 @@
////////////////////////////////////////////////////////////////////////////////
+__attribute__ ((visibility ("default")))
int read_file_eval_tlsh(char *fname, Tlsh *th, int show_details, int fc_cons_option, int showvers)
{
///////////////////////////////////////
@@ -402,6 +404,7 @@
return(err);
}
+__attribute__ ((visibility ("default")))
void freeFileName(struct FileName *fnames, int count)
{
for (int i=0; i<count; i++) {However, that's clearly not an optimal solution. I think it would be best if one of the followings could happen (this is not exhaustive, just what came to my mind):
- move those functions into the official public API/ABI
- make those functions static or inline, that should make the compiler pick them up earlier
- ... not sure about other options right away ...
Besides this, it would be nice if you could elaborate on what "problems" it was causing when "compiling / testing tools on Linux", as it's mentioned in src/CMakeLists.txt.
Thank you for considering at least! :)