Strange compilation problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
proxy

Re:Strange compilation problem

Post 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
aladdin

Re:Strange compilation problem

Post 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 ;)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Strange compilation problem

Post 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*/
aladdin

Re:Strange compilation problem

Post 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 ;)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Strange compilation problem

Post 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
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Strange compilation problem

Post by distantvoices »

aaahh, le francais ... cette langue est magnifique *gg*
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
dh

Re:Strange compilation problem

Post by dh »

[off topic]
my french is HORRIBLE, yet i live in a "bilingual" province.
[/off topic]
Post Reply