This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Linker script malfunctioning for cygwin -> powerpc-elf binutils


First off, here's the problem:
Certain memory segments (.rodata.cst4) are being relocated to the
beginning of ram, even though they are clearly specified in the linker
script to be part of the rest of the .rodata segments. There are only
two problem segments, as below, the rest of the .cst4 segments go where
they are supposed to. Here is the map file output showing the problem:

                0x00023708        0xf
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-strtod.o)
 *fill*         0x00023717        0x1 00
 .rodata        0x00023718      0x184
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-vfprintf.o)
 .rodata.cst4   0x00000000        0x4
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-vfprintf.o)
 .rodata.str1.4
                0x0002389c       0x5e
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-vfprintf.o)
 *fill*         0x000238fa        0x2 00
 .rodata        0x000238fc      0x101
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-ctype_.o)
                0x000238fc                _ctype_
 *fill*         0x000239fd        0x3 00
 .rodata        0x00023a00       0x18
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-dtoa.o)
 .rodata.cst4   0x00023a18       0x10
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-dtoa.o)
                                 0x24 (size before relaxing)
 .rodata.cst8   0x00023a28       0x18
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-dtoa.o)
 .rodata.str1.4
                0x00023a40       0x10
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-dtoa.o)
                                 0x12 (size before relaxing)
 .rodata.str1.4
                0x00023a50       0x1b
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-gdtoa-gethex.o)
 *fill*         0x00023a6b        0x1 00
 .rodata.str1.4
                0x00023a6c       0x10
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-locale.o)
                                 0x17 (size before relaxing)
 *fill*         0x00023a7c        0x4 00
 .rodata        0x00023a80      0x128
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-mprec.o)
                0x00023b80                __mprec_tinytens
                0x00023a80                __mprec_tens
                0x00023b58                __mprec_bigtens
 .rodata.cst4   0x00000000        0x8
C:\cross-gcc\powerpc-elf\lib/libc.a(lib_a-mprec.o)

Note the entries for mprec.o and vfprintf.o, while the ones for dtoa.o
is fine. Here is the part of my linker script that addresses this:

  .rodata	  :
  {
      *(.rodata)
      *(.rodata.*)
      *(.gnu.linkonce.r*)
  } > main_ram

What ends up happening is many of the re-entrant procedures try to read
from whatever's in memory address zero, which is usually a garbage
memory location, and crash my code! I was previously using a very old
version of LD which did not have this problem, but it ended up
overlapping variables which I couldn't exactly accept either.

The versions of tools I'm using is:
cygwin 1.5.25-15

bintools 20080624-2 (per Cygwin's version string; the -version command
gives 2.18.50.20080625)

gcc 4.3.2-1

newlib 1.16.0

All these packages, except newlib, where obtained with the Cygwin setup
"src" option.

Here was my build process:
************************************************************************
*********
* Binutils
************************************************************************
*********

#-----------------------------------------------------------------------
----------
# Source and Install directories
#-----------------------------------------------------------------------
----------

SRCDIR=/usr/src/binutils-20080624-2
prefix=/cygdrive/c/cross-gcc

#-----------------------------------------------------------------------
----------
# set the target and compiler flags
#-----------------------------------------------------------------------
----------
target=powerpc-elf

export CFLAGS='-O2 -pipe'
export CXXFLAGS='-O2 -pipe'
export LDFLAGS='-s'
export DEBUG_FLAGS=''
export CC='gcc-4'


#-----------------------------------------------------------------------
----------
# Build and install binutils
#-----------------------------------------------------------------------
----------

rm -rf build-binutils
mkdir -p build-binutils
cd build-binutils

$SRCDIR/configure --prefix=$prefix --target=$target \
    --disable-nls --disable-shared --enable-debug --disable-threads \
    --with-gcc --with-gnu-as --with-gnu-ld --with-stabs \
    --disable-multilib \
    2>&1 | tee binutils_configure.log

make    all 2>&1 | tee binutils_make.log
make    install 2>&1 | tee binutils_install.log

#-----------------------------------------------------------------------
----------
# Source and Install directories
#-----------------------------------------------------------------------
----------

SRCDIR=../../gcc-4.3.2
# the sourcecode dir for gcc
# This must be specified in the format shown here
# as one of the tools built during the process will fail
# if absolute paths are specified
# the example here assumes that the gcc source directory
# is at the same level as the script

#prefix=c:/cross-gcc
prefix=/cygdrive/c/cross-gcc
# installation directory
# This must be specified in the format shown here
# or gcc won't be able to find it's libraries and includes
# if you move the installation

************************************************************************
*********
* GCC
************************************************************************
*********

#-----------------------------------------------------------------------
----------
# set the path for the installed binutils
#-----------------------------------------------------------------------
----------

export PATH=${PATH}:/cygdrive/c/cross-gcc/bin

#-----------------------------------------------------------------------
----------
# set the target and compiler flags
#-----------------------------------------------------------------------
----------

target=powerpc-elf

export CFLAGS='-O2 -pipe'
export CXXFLAGS='-O2 -pipe'
export LDFLAGS='-s'
export DEBUG_FLAGS=''
export CC='gcc-4'

#-----------------------------------------------------------------------
----------
# build and install just the c compiler
#-----------------------------------------------------------------------
----------

rm -rf gcc-build/$target
mkdir -p gcc-build/$target
cd gcc-build/$target


$SRCDIR/configure \
        --enable-languages=c,c++ \
        --disable-multilib\
        --with-gcc --with-gnu-ld --with-gnu-as --with-stabs \
        --disable-shared --disable-threads --disable-win32-registry
--disable-nls\
        --target=$target \
        --with-newlib \
        --prefix=$prefix -v\
        2>&1 | tee gcc_configure.log

make all-gcc | tee make-c-only.log 2>&1
make install-gcc | tee install-c-only.log 2>&1

************************************************************************
*********
* Newlib
************************************************************************
*********
#-----------------------------------------------------------------------
----------
# Source and Install directories
#-----------------------------------------------------------------------
----------

SRCDIR=/usr/src/newlib-1.16.0
prefix=/cygdrive/c/cross-gcc
#-----------------------------------------------------------------------
----------
# set the path for the installed binutils and C compiler
#-----------------------------------------------------------------------
----------

export PATH=${PATH}:/cygdrive/c/cross-gcc/bin

#-----------------------------------------------------------------------
----------
# set target and compiler flags
#-----------------------------------------------------------------------
----------

target=powerpc-elf

export CC='gcc-4'
export CFLAGS='-O2 -pipe'
export CXXFLAGS='-O2 -pipe'
export LDFLAGS='-s'
export DEBUG_FLAGS=''

#-----------------------------------------------------------------------
----------
# Build and install newlib
#-----------------------------------------------------------------------
----------

rm -r build-newlib
mkdir -p build-newlib
cd build-newlib

$SRCDIR/configure\
        --target=$target --prefix=$prefix \
        2>&1 | tee newlib_configure.log

make all 2>&1 | tee newlib_make.log
make install 2>&1 | tee newlib_install.log


Any help would be appreciated.

Thanks,
Ryan

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]