Possible Bug with darwin_asm_named_section() in gcc/config/darwin.c
Andrew Pinski
pinskia@gmail.com
Fri Jul 2 07:33:00 GMT 2010
On Jul 1, 2010, at 11:29 PM, Eric Siroker <esiroker@gmail.com> wrote:
> Hello Darwin port maintainers,
>
> I'm getting the frontend for the Go programming language to work in
> Darwin. I encountered what looks like a bug in Darwin-specific gcc
> code.
>
> The Go frontend saves language-specific export information in the
> object file inside a special section. This works fine in Linux/ELF.
> In Darwin/Mach-O, the following assembly is generated for the section
> header (.go_export is the segment name):
>
> .section .go_export
You need the segment name besides just the section name. Mach-o is
different from elf that it has segments and sections. Look into the
trunk to see how the lto sections are defined and use that as a
template.
>
> The Darwin assembler installed on my Mac (cctools-773~33, GNU
> assembler version 1.38) however doesn't like this statement. It
> produces this error message when fed the aforementioned assembly:
>
> Expected comma after segment-name
>
> If I modify darwin_asm_named_section() in gcc/config/darwin.c:
>
> - fprintf (asm_out_file, "\t.section %s\n", name);
> +fprintf (asm_out_file, "\t.section %s,\n", name);
>
> The following assembly is produced by gcc and accepted by the
> assembler:
>
> .section .go_export,
>
> Apple's documentation confirms a comma is required for .section:
> http://developer.apple.com/mac/library/documentation/DeveloperTools/Reference/Assembler/040-Assembler_Directives/asm_directives.html
>
> Can you please explain either why darwin_asm_named_section() is
> correct as written or can you apply this fix? Thank you.
>
> If you're interested in observing the issue yourself, the Go branch is
> located in the main gcc source repository in this subdirectory:
>
> /branches/gccgo
>
> Here is a sample Go program that, when compiled with gccgo, will
> exhibit the issue:
>
> package main
> func Main() {}
>
> I use the following configure arguments: --disable-bootstrap
> --enable-languages=go
>
> Eric
More information about the Gcc
mailing list