Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Feb 2011 03:03:08 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Jung-uk Kim <jkim@FreeBSD.org>
Cc:        Rui Paulo <rpaulo@gmail.com>, freebsd-current@FreeBSD.org
Subject:   Re: binutils 2.17.50 and ctfconvert
Message-ID:  <4D646ADC.9090804@FreeBSD.org>
In-Reply-To: <201102221423.30652.jkim@FreeBSD.org>
References:  <201102221423.30652.jkim@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------090008070301020106080100
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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 :)

--------------090008070301020106080100
Content-Type: text/plain;
 name="librt-ctf-1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="librt-ctf-1.diff"

Index: lib/librt/Makefile
===================================================================
--- lib/librt/Makefile	(revision 218951)
+++ lib/librt/Makefile	(working copy)
@@ -6,7 +6,7 @@
 .ifndef NO_THREAD_STACK_UNWIND
 CFLAGS+=-fexceptions
 .endif
-CFLAGS+=-Winline -Wall -g
+CFLAGS+=-Winline -Wall
 DPADD=	${LIBPTHREAD}
 LDADD=	-lpthread
 

--------------090008070301020106080100--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D646ADC.9090804>