This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

User defined sections


Hello,

I'm trying to create a program with a custum section. This doesn't seem to
work; ld.so crashes on it.

I have generated my custom section with Nasm:

[SECTION .custom exec write alloc]

some_data:      db 'This is some data...'


Then I have modified the default linker script to load it at the fixed
address 0 (other fixed addresses also cause problems). Here are the first
lines:

SECTIONS
{
  . = 0;
  .custom      : { *(.custom) }
  /* Read-only sections, merged into text segment: */
  . = 0x20000000 + SIZEOF_HEADERS;
  .interp     : { *(.interp)    }
  .hash          : { *(.hash)           }
  .dynsym        : { *(.dynsym)         }
  .dynstr        : { *(.dynstr)         }
  .gnu.version   : { *(.gnu.version)    }


Then a small test program:

#include <stdlib.h>
#include <stdio.h>

int main() {
    printf("If this appears on the screen there is no problem.\n");
};

And a makefile:

problem: problem.o image.o
        gcc -Xlinker -T -Xlinker link.res -o problem problem.o image.o

problem.o: problem.c
        gcc -o problem.o problem.c

image.o:
        nasm -F elf -o image.o image.asm


Why doesn't this work? Am I doing something wrong or is this a bug in
ld.so?

I have placed these files on the web at
http://darkstar.vhl.tudelft.nl/customsection

Greetings,

DaniŽl Mantione


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