Page 3 of 3

Re:Strange compilation problem

Posted: Wed Jan 19, 2005 1:34 am
by proxy
a while back i experienced a similar problem after upgrading versions of gcc where the gnu folk had decided to create some new sections and relocate some code to them.

after some small alterations to my linker script it now works again..here is my linker script (c++ kernel)

Code: Select all

OUTPUT_FORMAT("elf32-i386")
ENTRY(start)

virt = 0xc0100000; /* 3.1 gig */
phys = 0x00100000; /* 1 meg */

SECTIONS
{ 
  .text virt : AT(phys) 
  {
    code = .; _code = .; __code = .;
    *(.text)
   *(.gnu.linkonce.t*)
    . = ALIGN(4096); 
  }
  
  .rodata : AT(phys + (rodata - code))
  {
     rodata = .; _rodata = .; __rodata = .;
     *(.rodata*)
   *(.gnu.linkonce.r*)
    . = ALIGN(4096); 
  }
  
  .data : AT(phys + (data - code))
  {
    data = .; _data = .; __data = .;   
    *(.data)
   
   __CTOR_LIST__ = .; 
   LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 
   *(.ctors) 
   LONG(0) 
   __CTOR_END__ = .; 
   
   __DTOR_LIST__ = .; 
   LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 
   *(.dtors) 
   LONG(0) 
   __DTOR_END__ = .; 
   
   *(.gnu.linkonce.d*)
   
    . = ALIGN(4096); 
   
  }
  
  .bss : AT(phys + (bss - code)) 
  {
    bss = .; _bss = .; __bss = .;
    *(.bss)
    *(COMMON)
   *(.gnu.linkonce.b*)
    . = ALIGN(4096); 
  }
   
  end = .; _end = .; __end = .;
}


for me the relavant sections where the gnu.linkonce.* ones..you may want to look into them.

proxy

Re:Strange compilation problem

Posted: Wed Jan 19, 2005 3:45 am
by aladdin
@proxy : thank you this can help me

i tried to add gnu.linkonce. to my sections but still have the same problem, but when i added the folowing lines at the end of my ld script :

Code: Select all

      /DISCARD/ : { *(.comment) }
      /DISCARD/ : { *(.note.GNU-stack) }
the text is now printed at the top of the screen (this meen that datas are now in the good place), but it still hangs when it try to call the pointer to function, i think there is an alignement problem with bss...

i'll keep trying with your ldscript this night ;)

Re:Strange compilation problem

Posted: Wed Jan 19, 2005 4:43 am
by Pype.Clicker
have you tried clearing out your BSS section ? it worked for me

Code: Select all

int _start( void* mbd, unsigned int magic ) {
   unsigned char m=0;

        extern char edata, ebss;
        char* clear;

        for (clear=&edata;clear<&ebss;clear++)
          *clear=0;


/*PARTIE 0*/

Re:Strange compilation problem

Posted: Wed Jan 19, 2005 6:29 am
by aladdin
@Pype.Clicker : thank you very much, that's work ;D

but still don't understand why it was working with old linked and don't with the new one ???


BTW : i didn't know that we can access ld script variabls from C code ;)

Re:Strange compilation problem

Posted: Wed Jan 19, 2005 6:38 am
by Pype.Clicker
aladdin wrote: @Pype.Clicker : thank you very much, that's work ;D

but still don't understand why it was working with old linked and don't with the new one ???


BTW : i didn't know that we can access ld script variabls from C code ;)
see <explanation/> above ...

1. the old code leave no "comment" section, so there's nothing in memory at the place where .bss should be... thus it's read as zeroes (as expected, but by chance) on emulators ... on real hardware, it may not work.

or
2. the old code *had* comment, but it had more space wasted in 0-padding so the chance are good that your last-used-index byte *actually* contains 0 ...

PS: si t'y comprends plus rien, contacte-moi par ICQ et je te r?explique :P

Re:Strange compilation problem

Posted: Wed Jan 19, 2005 7:23 am
by distantvoices
aaahh, le francais ... cette langue est magnifique *gg*

Re:Strange compilation problem

Posted: Wed Jan 19, 2005 10:56 am
by dh
[off topic]
my french is HORRIBLE, yet i live in a "bilingual" province.
[/off topic]