[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] Compiling against libwget built with ubsan
From: |
Tim Rühsen |
Subject: |
Re: [Bug-wget] Compiling against libwget built with ubsan |
Date: |
Tue, 29 Aug 2017 17:12:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
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
signature.asc
Description: OpenPGP digital signature