Bug 14779 - readelf.c:403:3: error: unknown type name 'mbstate_t'
Summary: readelf.c:403:3: error: unknown type name 'mbstate_t'
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: 2.24
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-28 06:41 UTC by John David Anglin
Modified: 2015-05-04 00:13 UTC (History)
3 users (show)

See Also:
Host: hppa1.1-hp-hp10.20
Target: hppa1.1-hp-hp10.20
Build: hppa1.1-hp-hp10.20
Last reconfirmed:


Attachments
Proposed patch (1.99 KB, patch)
2012-10-30 12:02 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2012-10-28 06:41:56 UTC
gcc -DHAVE_CONFIG_H -I. -I../../src/binutils  -I. -I../../src/binutils -I../bfd -I../../src/binutils/../bfd -I../../src/binutils/../include -DHOST_HPPAHPUX -D_LARGEFILE64_SOURCE -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I/usr/local/include -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT readelf.o -MD -MP -MF .deps/readelf.Tpo -c -o readelf.o ../../src/binutils/readelf.c
../../src/binutils/readelf.c: In function 'print_symbol':
../../src/binutils/readelf.c:403:3: error: unknown type name 'mbstate_t'
../../src/binutils/readelf.c:460:4: warning: implicit declaration of function 'mbrtowc' [-Wimplicit-function-declaration]
make[4]: *** [readelf.o] Error 1

'mbstate_t' and 'mbrtowc' are not supported.

Have:
     extern int mblen(const char *, size_t);
     extern int mbtowc(wchar_t *, const char *, size_t);
     extern int wctomb(char *, wchar_t);
     extern size_t mbstowcs(wchar_t *, const char *, size_t);
     extern size_t wcstombs(char *, const wchar_t *, size_t);
Comment 1 Nick Clifton 2012-10-30 12:02:14 UTC
Created attachment 6710 [details]
Proposed patch
Comment 2 Nick Clifton 2012-10-30 12:03:05 UTC
Hi John,

  Please could you try out the uploaded patch and let me know if it works for you.

Cheers
  Nick
Comment 3 Sourceware Commits 2012-10-30 12:45:08 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2012-10-30 12:44:58

Modified files:
	bfd            : ChangeLog elf-bfd.h elf32-arm.c elflink.c 
	binutils       : ChangeLog bfdtest1.c config.in configure 
	                 configure.in readelf.c 
	elfcpp         : ChangeLog arm.h 
	gas/doc        : as.texinfo 
	gold           : ChangeLog arm.cc 
	include/elf    : ChangeLog arm.h 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-arm: arm-elf.exp 

Log message:
	bfd:
	* elf32-arm.c (elf32_arm_print_private_bfd_data): Recognise and
	display the new ARM hard-float/soft-float ABI flags for EABI_VER5
	(elf32_arm_post_process_headers): Add the hard-float/soft-float
	ABI flag as appropriate for ET_DYN/ET_EXEC in EABI_VER5.
	
	binutils:
	* readelf.c (decode_ARM_machine_flags): Recognise and display the
	new ARM hard-float/soft-float ABI flags for EABI_VER5. Split out
	the code for EABI_VER4 and EABI_VER5 to allow this.
	
	elfcpp:
	* arm.h: New enum for EABI soft- and hard-float flags.
	
	gold:
	* gold.cc (Target_arm::do_adjust_elf_header): Add the
	hard-float/soft-float ABI flag as appropriate for ET_DYN/ET_EXEC
	in EABI_VER5.
	
	include:
	* elf/arm.h (EF_ARM_ABI_FLOAT_SOFT): New define.
	(EF_ARM_ABI_FLOAT_HARD): Likewise.
	
	ld/testsuite:
	* ld-arm/eabi-hard-float.s: New test source.
	* ld-arm/eabi-soft-float.s: New test source.
	* ld-arm/eabi-hard-float.d: New test.
	* ld-arm/eabi-soft-float.d: New test.
	* ld-arm/eabi-soft-float-ABI4.d: New test.
	* ld-arm/eabi-soft-float-r.d: New test.
	* ld-arm/arm-elf.xp: Use the new tests.
	
	binutils:
	PR binutils/14779
	* configure.in: Add checks for wchar.h and mbstate_t.
	* config.in: Regenerate.
	* configure: Regenerate.
	* readelf.c: Conditionally include wchar.h.
	(print_symbol): Conditionally use mbstate_t.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5835&r2=1.5836
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&r1=1.348&r2=1.349
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-arm.c.diff?cvsroot=src&r1=1.300&r2=1.301
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.455&r2=1.456
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1950&r2=1.1951
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/bfdtest1.c.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/config.in.diff?cvsroot=src&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/configure.diff?cvsroot=src&r1=1.152&r2=1.153
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/configure.in.diff?cvsroot=src&r1=1.113&r2=1.114
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/readelf.c.diff?cvsroot=src&r1=1.583&r2=1.584
http://sourceware.org/cgi-bin/cvsweb.cgi/src/elfcpp/ChangeLog.diff?cvsroot=src&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/src/elfcpp/arm.h.diff?cvsroot=src&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/doc/as.texinfo.diff?cvsroot=src&r1=1.259&r2=1.260
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.984&r2=1.985
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&r1=1.156&r2=1.157
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/ChangeLog.diff?cvsroot=src&r1=1.448&r2=1.449
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/arm.h.diff?cvsroot=src&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1614&r2=1.1615
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-arm/arm-elf.exp.diff?cvsroot=src&r1=1.97&r2=1.98
Comment 4 dave.anglin 2012-10-30 18:05:55 UTC
Hi Nick,

On 10/30/2012 8:03 AM, nickc at redhat dot com wrote:
>    Please could you try out the uploaded patch and let me know if it works for
> you.
The patch works fine.

I'm going to retest removing --disable-werror.  Think there are
a couple of unrelated warnings that need fixing.

Thanks,
Dave
Comment 5 dave.anglin 2012-10-30 22:59:15 UTC
On 30-Oct-12, at 8:45 AM, cvs-commit at gcc dot gnu.org wrote:

>   binutils:
>    PR binutils/14779
>    * configure.in: Add checks for wchar.h and mbstate_t.
>    * config.in: Regenerate.
>    * configure: Regenerate.
>    * readelf.c: Conditionally include wchar.h.
>    (print_symbol): Conditionally use mbstate_t.

Bug is also present in 2.23.

--
John David Anglin	dave.anglin@bell.net
Comment 7 Jan Smets 2013-04-18 19:38:38 UTC
I think this broke cross compilation for i386-mingw (gcc 3.4)

readelf.o: In function `print_symbol':
binutils-2.23.2/binutils/readelf.c:469: undefined reference to `_mbrtowc'
Comment 8 Antoine Leca 2015-02-04 10:50:44 UTC
(In reply to Jan Smets from comment #7)
> I think this broke cross compilation for i386-mingw (gcc 3.4)
> 
> readelf.o: In function `print_symbol':
> binutils-2.23.2/binutils/readelf.c:469: undefined reference to `_mbrtowc'

Solved for me. As made clear in MingW's include/wchar.h

/* These are resolved by -lmingwex. Alternatively, they can be resolved by
   adding -lmsvcp60 to your command line, which will give you the VC++
   versions of these functions. If you want the latter and don't have
   msvcp60.dll in your windows system directory, you can easily obtain
   it with a search from your favorite search engine.  */

Earlier (obsolete) versions of Mingw-rt did not mention -lmingwex.
Adding LIBS=-lmsvcp60 in the binutils/Makefile did the job for me.
Comment 9 H.J. Lu 2015-05-04 00:13:52 UTC
Fixed.