On 08/29/2017 05:03 PM, Avinash Sonawane wrote:
> Hello!
> 
> $ cat foo.c
> #include <stdio.h>
> #include <wget.h>
> 
> int main(int argc, char **argv)
> {
>     char foo[] = "FOO";
>     printf("%s\n", wget_strtolower(foo));
> 
>     return 0;
> }
> 
> $ gcc -lwget foo.c -o foo
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_divrem_overflow_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_add_overflow_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_negate_overflow_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_out_of_bounds_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_mul_overflow_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_vla_bound_not_positive_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_load_invalid_value_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_float_cast_overflow_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_type_mismatch_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_sub_overflow_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_nonnull_arg_abort'
> //usr/local/lib/libwget.so: undefined reference to
> `__ubsan_handle_shift_out_of_bounds_abort'
> collect2: error: ld returned 1 exit status
> 
> If I compile libwget without --fsanitize-ubsan then the object files
> get linked as expected. But how to use libwget when it's compiled with
> ubsan?
> 
> PS - I know this is not a libwget question per-se. But a library
> linker issue. Nevertheless, any pointers will be highly appreciated!

If you compile wget2/libwget with -fsanitize=undefined, then you have to
use this flag later as well, so that the right libubsan gets linked.

gcc -fsanitize=undefined -lwget foo.c -o foo


Regards, Tim

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to