bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking against signed integer overflow


From: Paul Eggert
Subject: Re: checking against signed integer overflow
Date: Sun, 6 Dec 2020 10:09:28 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0

On 12/6/20 9:00 AM, Bruno Haible wrote:

The solution to this problem is to use the option '-static-libubsan'.

Unfortunately -static-libusan doesn't solve the whole problem of dynamically linking to extra libraries, and it introduces problems of its own. When I build your foo.c program on Fedora 33 x86-64:

$ gcc -O2 foo.c
$ size a.out
   text    data     bss     dec     hex filename
   1231     548      12    1791     6ff a.out
$ ldd a.out
        linux-vdso.so.1 (0x00007ffe583c8000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f60a557f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f60a576e000)
$ gcc -fsanitize=undefined -fsanitize-undefined-trap-on-error -O2 foo.c
$ size a.out
   text    data     bss     dec     hex filename
   1247     548      12    1807     70f a.out
$ ldd a.out
        linux-vdso.so.1 (0x00007ffe0b100000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f79f2d98000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f79f2f87000)
$ gcc -fsanitize=undefined -static-libubsan -O2 foo.c
$ size a.out
   text    data     bss     dec     hex filename
 274576   15912  593416  883904   d7cc0 a.out
$ ldd a.out
        linux-vdso.so.1 (0x00007ffe15d15000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f0bc6af6000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f0bc6aeb000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f0bc6ac9000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f0bc6983000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f0bc6968000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f0bc679d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0bc6b21000)
$ gcc -fsanitize=undefined -O2 foo.c
$ size a.out
   text    data     bss     dec     hex filename
   1511     660      12    2183     887 a.out
$ ldd a.out
        linux-vdso.so.1 (0x00007ffc208cd000)
        libubsan.so.1 => /lib64/libubsan.so.1 (0x00007fac5540e000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fac55243000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fac5523c000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fac55231000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fac5520f000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fac55027000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fac54edf000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fac54ec4000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fac55d9d000)

I tried to condense all this into something short and installed the attached into the Gnulib manual.

Attachment: 0001-doc-document-static-libubsan-more.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]