gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > GCC 3.3.2 Overlaps Section

#17664 - bogston - Fri Mar 12, 2004 2:24 am

This is from linux.gbadev.org:

binutils-2.11.2.tar.bz2
assembler, linker, objcopy, other goodies...
(versions newer than this create overlap errors with crt0.o?)
(some of them complain about --mcpu=arm7tdmi with certain versions of gcc! I am experimenting)

GCC 3.3.2 introduced to sections: .init and .fini. The source of these sections is gcc.3.3.2/gcc/config/arm/crti.asm and crtn.asm. Neither section is defined in Jeff Frohwein's lnkscript. If I define these sections in lnkscript, GCC 3.3.2 compiles and links linux.gbadev.org/test.tar.gz without errors although the binary does not appear to execute properly in VisualBoyAdvanced. (I don't see the dot.)

Now, I have no idea how to properly define these sections in lnkscript. I have made several attempts. Does anyone have any ideas how to modify lnkscript or if lnkscript is even the source of the overlapping section errors?

#17980 - bogston - Thu Mar 18, 2004 1:22 am

Here's my contribution to anyone wishing to develop for the GameBoy Advance using GCC and Linux. Thanks to everyone who gave me advice at http://forum.gbadev.org. Here's what I learned.

I got this configuration to produce a binary that VisualBoyAdvance 1.7 will execute: gcc-core-3.3.2.tar.gz, binutils-2.14.tar.gx, and newlib-1.12.tar.gz. The OS is Red Hat 8.0 (kernel 2.4.20-28.8). Believe me, it took a lot of effort.

GCC must be built to produce soft float operations by default. Look at this thread:
http://sources.redhat.com/ml/crossgcc/2004-01/msg00173.html (thanks Torlus).

Afer applying the patch above, follow the instructions given at http://linux.gbadev.org for building a ARM GCC cross compiler. These instructions are general enough to apply to any GCC version.

At this point, GCC will not build a binary properly. The message says something about ".data overlaps section .init" and ".jcr overlaps section .fini" etc. This message appears because GCC 3.1 and above contains to two new sections .init and .fini. These sections are for global constructors and destructors in C++. Here's the two workarounds:

1.) Add --no-warn-mismatch option to ld. This is given often by others as a fix. I don't like fixes that simply turn off warnings. Your choice.

2.) Modify lnkscript from Jeff Frohwein (http://www.devrs.com) to add the new sections. Below are the changes I made. I have no idea if this is good or not, but it does work on the examples I have tried.

SECTIONS

{

.text __text_start : /* ALIGN (4): */

{

*(EXCLUDE_FILE (*text.iwram*) .text)

*(.text.*)

*(.init)

*(.fini)

*(.stub)

/* .gnu.warning sections are handled specially by elf32.em. */

*(.gnu.warning)

*(.gnu.linkonce.t*)

*(.glue_7)

*(.glue_7t)

. = ALIGN(4); /* REQUIRED. LD is flaky without it. */

} = 0xff



__text_end = .;



.init :

{

KEEP (*(.init))

}



.fini :

{

KEEP (*(.fini))

}


At this point, GCC will produce a binary that will execute in VisualBoyAdvance.

bogston