Bug 13409

Summary: windres should specify host endianness for iconv explicitly
Product: binutils Reporter: Yuji Kuwabara <HHG01200>
Component: binutilsAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: critical CC: nickc, phil.krylov
Priority: P2    
Version: 2.24   
Target Milestone: ---   
Host: FreeBSD, Mac OS X (little-endian) Target: i386-mingw32msvc (little-endian)
Build: Last reconfirmed:
Project(s) to access: ssh public key:
Bug Depends on:    
Bug Blocks: 11337    
Attachments: Patch against version 2.22

Description Yuji Kuwabara 2011-11-14 11:04:49 UTC
I installed binutils onto Mac OSX (host, i686 little endian) for mingw32msvc (target, i386 little endian).
windres writes resource id and name string (not integer) in big endian into COFF.
I investigated a function  wind_MultiByteToWideChar() in "winduni.c" .
I changed an argument,
  iconv_open ("UTF-16", iconv_name);
to
  iconv_open ("UTF-16LE", iconv_name);

This fixed the problem.

Regards.
Comment 1 Yuji Kuwabara 2011-11-14 13:04:45 UTC
Sorry, these are resource type and resource name (not ID).

Regards.
Comment 2 Phil Krylov 2012-06-07 21:06:57 UTC
Same with version 2.22 of binutils and FreeBSD6.
Comment 3 Phil Krylov 2012-06-07 21:32:37 UTC
Created attachment 6441 [details]
Patch against version 2.22
Comment 4 Phil Krylov 2012-06-30 15:45:48 UTC
The bug is present in 2.21, 2.22, and 2.23 (HEAD)
Comment 5 Sourceware Commits 2013-03-27 11:53:48 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2013-03-27 11:53:46

Modified files:
	binutils       : ChangeLog winduni.c 

Log message:
	PR binutils/13409
	* winduni.c (codepages[]): Use UTF-16LE.
	(wind_MultiByteToWideChar): Likewise.
	(wind_WideCharToMultiByte): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.2006&r2=1.2007
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/winduni.c.diff?cvsroot=src&r1=1.15&r2=1.16
Comment 6 Nick Clifton 2013-03-27 11:54:55 UTC
Hi Yuji, Hi Phil,

      Thanks for the bug report.  I have applied Phil's patch.

heers
      Nick
Comment 7 Phil Krylov 2013-03-27 12:07:11 UTC
Thanks, Nick.