Re: binutils 2.17.50 and ctfconvert

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 23 Feb 2011 03:03:08 +0100
On 2011-02-22 20:23, Jung-uk Kim wrote:
> Since binutils 2.17.50 import, WITH_CTF=1&  buildworld on amd64 stops
> like this:
...
> cc -m32 -march=i686 -mmmx -msse -msse2 -mfancy-math-387 -DCOMPAT_32BIT
> -isystem /usr/obj/usr/src/lib32/usr/include/
> -L/usr/obj/usr/src/lib32/usr/lib32
> -B/usr/obj/usr/src/lib32/usr/lib32 -fpic -DPIC -O2 -pipe
> -fno-omit-frame-pointer -I/usr/src/lib/librt/../libc/include
> -I/usr/src/lib/librt -fexceptions -Winline -Wall -g -std=gnu99
> -fstack-protector -Wsystem-headers -Werror -Wall -Wno-format-y2k
> -Wno-uninitialized -Wno-pointer-sign -c /usr/src/lib/librt/aio.c -o
> aio.So
> ctfconvert -L VERSION aio.o
...
> BFD: aio.So: invalid SHT_GROUP entry
> BFD: aio.So: invalid SHT_GROUP entry
> BFD: aio.So: no group info for section .text.__i686.get_pc_thunk.cx
> BFD: aio.So: no group info for section .text.__i686.get_pc_thunk.bx
> BFD: aio.So: unknown [0] section `' in group [__i686.get_pc_thunk.cx]
> BFD: aio.So: unknown [0] section `' in group [__i686.get_pc_thunk.bx]
> nm: aio.So: File format not recognized
...
> Google found NetBSD has a similar looking PR but it is not exactly the
> same:
>
> http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=42986

What I gather from that bug report is that apparently ctfconvert can
corrupt object files with debug info, if you do not pass -g to it.

There is some logic in bsd.lib.mk to add '-g' to CTFFLAGS, if
DEBUG_FLAGS contains '-g', but in lib/librt/Makefile you can see:

...
CFLAGS+=-Winline -Wall -g
...

It looks like the -g flag is not detected, so ctfconvert is run without
-g, and it corrupts the .So file.  I have no clue yet why this suddenly
appears after upgrading to binutils 2.17.50, but it is likely due to a
slightly different output format.

In any case, just removing the -g from CFLAGS in lib/librt/Makefile made
the build32 stage complete successfully for me, and since that is the
lsat stage of the amd64 build, I assume the rest will be OK too.

For now, I propose to commit the attached diff, and then we try to find
out why:

1) ctfconvert does not get -g passed when it is needed
2) ctfconvert corrupts .o files when -g is not passed :)

Received on Wed Feb 23 2011 - 01:03:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:11 UTC