Linker Syntax Error

Programming, for all ages and all languages.
Post Reply
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Linker Syntax Error

Post by Mehmetdev1 »

Hello, I'm getting Linker Syntax Error on Line 21. What is the solution for the error I will write the code here?



ENTRY(loader)
OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386:i386)

SECTIONS
{
. = 0x0100000;

.text :
{
*(.multiboot)
*(.text*)
*(.rodata)
}

.data :
{
start_ctors = .;
KEEP(*( .init_array ));
KEEP(*(SORT_BY_INIT_PRIOTRY( .init_array.* )));
end_ctors = .;

*(.data)
}

.bss :
{
*(.bss)
}

/DISCARD/ :
}
*(.fini_array*)
*(.comment)
}
}
Attachments
Ekran görüntüsü 2022-03-31 201702.png
M. Alp
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Linker Syntax Error

Post by klange »

Please try to use the [code] markup when posting code snippets.

You have a typo that I suspect is the source of the issue: SORT_BY_INIT_PRIOTRY should be SORT_BY_INIT_PRIORITY
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: Linker Syntax Error

Post by Mehmetdev1 »

Code: Select all

ENTRY(loader)
OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386:i386)

SECTIONS
{
 . = 0x0100000;

  .text :
  {
     *(.multiboot) 
     *(.text*)
     *(.rodata)
  }

  .data :
  {
    start_ctors = .;
    KEEP(*(  .init_array ));
    KEEP(*(SORT_BY_INIT_PRIORITY( .init_array.*  )));
    end_ctors = .;

    *(.data)
  }

   .bss :
   {
    *(.bss)  
   }

/DISCARD/ : 
 }
    *(.fini_array*)
   *(.comment)
 }
}
Yes, This Solved My Code Error On Line 21, But Now Line 33 Has The Same Linker Error. I'm Posting the Screenshot.
Attachments
Linker 33 Satırdakş Hata.png
M. Alp
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Linker Syntax Error

Post by klange »

On the line after "/DISCARD/ :" you have a closing curly brace } when you want an opening one {

I would have thought binutils ld would print better messages than just "syntax error" and I wonder if something is wrong with your language configuration since it looks like you're using Turkish? Before you fix the above issue, can you try putting LANG=C before your make command? I want to see if this produces more useful output.
Post Reply