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

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

Reply via email to