On Fri, Mar 22, 2013 at 3:01 PM, David Coppa <[email protected]> wrote:
> On Thu, Mar 21, 2013 at 11:34 PM, Stuart Henderson <[email protected]> 
> wrote:
>> On 2013/03/21 21:54, Miod Vallat wrote:
>>> > - www/chromium - OSError: [Errno 8] Exec format error
>>>
>>> Please make the binary available to me offlist, as well as its linking
>>> command (or build log, whatever suits you).
>>
>> Well this is very strange because if I run the program which generates
>> the error message under ktrace -i, there is no ENOEXEC...
>>
>> python ../tools/protoc_wrapper/protoc_wrapper.py --include "" --protobuf 
>> "/usr/obj/chromium-25.0.1364.173/chromium-25.0.1364.173/out/Release/obj/gen/protoc_out/chrome/common/metrics/proto/chrome_experiments.pb.h"
>>  --proto-in-dir common/metrics/proto --proto-in-file 
>> "chrome_experiments.proto" "--use-system-protobuf=0" -- 
>> "/usr/obj/chromium-25.0.1364.173/chromium-25.0.1364.173/out/Release/protoc" 
>> --cpp_out 
>> "/usr/obj/chromium-25.0.1364.173/chromium-25.0.1364.173/out/Release/obj/gen/protoc_out/chrome/common/metrics/proto"
>>  --python_out 
>> "/usr/obj/chromium-25.0.1364.173/chromium-25.0.1364.173/out/Release/pyproto/chrome/common/metrics/proto"
>
> I think this is related to a binutils bug with "-Wl,--gc-sections".
>
> This BZ may be related: http://sourceware.org/bugzilla/show_bug.cgi?id=13195
>
> With binutils-2.15, you have:
>
> $ g++ test.C -ffunction-sections -Wl,--gc-sections
> /usr/bin/ld: Warning: gc-sections option ignored
>
> And the resulting binary seems sane.
>
> With 2.17 instead:
>
> $ g++ test.C -ffunction-sections -Wl,--gc-sections
> $
>
> But the resulting binary is crap:
>
> $ ldd a.out
> a.out:
> a.out: Exec format error
> a.out: exit status 1
> $
>
> $ ./a.out[1]:  ELF    : not found
> ./a.out[7]: cannot open
> ÑuõH ZþL dÐøHƒûÿt ff ff Hƒë I‹ ƒì ÿÐHƒûÿuì[AÉÃfff ff UH‰åSHƒì H‹ ˆ 0H…Àt H  :
> No such file or directory
> ./a.out[7]:  : not found
> ./a.out: syntax error: `)' unexpected
> ./a.out[7]:  0fff ÿÐH‹C HƒÃ H…ÀuñHƒÄ [ÉÃfff ff ff U‹ Í @H‰å…Àt ÉÃÇ º @ Éë£ff 
> U‹ © @H‰å…Òt ÉÃH 5¹ @H =z  Ç ˆ @ è ÿÿÿHƒ=[ :
> not found
> ./a.out[7]: ÿïÿX Œÿïÿx Îÿïÿ˜   zR x       $ ÈüïÿâA  † C
>  DŒ   Dƒ  D ýïÿ A  † C
>   d€ýïÿYA  † K
>  Cƒ Œ  „Àýïÿ6A  † C
>  Eƒ  ¤àýïÿ A  † I
>   Äàýïÿ_A  † I
>    zPLR x  ›} 0       $þïÿ+ A  † C
>   D þïÿA GA  † C
>   d.þïÿ: not found
> ./a.out[7]: 7     ° @ Ø   ø  8  À: not found
> ./a.out[7]: T: not found
> ./a.out[8]:  : not found
> ./a.out[9]: syntax error: `&' unexpected
>
>
> cheers,
> David

Hi again,

Revision 244600 from FreeBSD fixes this problem:

http://svnweb.freebsd.org/base?view=revision&revision=244600

"Fix a bug in ld --gc-sections: it strips out .note sections, while it
should never do so.  This can cause global constructors and destructors
to not be executed at run-time, resulting in crashes and other strange
behaviour."

Attached you have the diff for our tree.

ciao,
David

Attachment: elflink.patch
Description: Binary data

Reply via email to