ld ignores additional pathes - c++

I'm am trying to compile a C++ program that uses Gurobi. The problem is that ld cannot find the library although ldconfig sees it. I also tried to configure the LD_LIBRARY_PATH variable without success
$ sudo ldconfig -v
...
/opt/gurobi701/linux64/lib:
libgurobi.so.7.0.1 -> libgurobi.so.7.0.1
libaes70.so -> libaes70.so
libGurobiJni70.so -> libGurobiJni70.so
...
$ echo $LD_LIBRARY_PATH
:/opt/gurobi701/linux64/lib
$ ld -lgurobi_c++ --verbose
GNU ld (GNU Binutils for Ubuntu) 2.26.1
Émulations prises en charge :
elf_x86_64
elf32_x86_64
elf_i386
elf_iamcu
i386linux
elf_l1om
elf_k1om
i386pep
i386pe
utilisation du script interne d'édition de liens :
==================================================
/* Script for -z combreloc: combine and sort reloc sections */
/* Copyright (C) 2014-2015 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
"elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu"); SEARCH_DIR("=/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("=/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("=/usr/x86_64-linux-gnu/lib");
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
*(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*)
*(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*)
*(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*)
*(.rela.ifunc)
}
.rela.plt :
{
*(.rela.plt)
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
.init :
{
KEEP (*(SORT_NONE(.init)))
}
.plt : { *(.plt) *(.iplt) }
.plt.got : { *(.plt.got) }
.plt.bnd : { *(.plt.bnd) }
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
}
.fini :
{
KEEP (*(SORT_NONE(.fini)))
}
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
.gcc_except_table.*) }
.gnu_extab : ONLY_IF_RO { *(.gnu_extab*) }
/* These sections are generated by the Sun/Oracle C++ compiler. */
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
.exception_ranges*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
.got : { *(.got) *(.igot) }
. = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
.got.plt : { *(.got.plt) *(.igot.plt) }
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
. = .;
__bss_start = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
.lbss :
{
*(.dynlbss)
*(.lbss .lbss.* .gnu.linkonce.lb.*)
*(LARGE_COMMON)
}
. = ALIGN(64 / 8);
. = SEGMENT_START("ldata-segment", .);
.lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
{
*(.lrodata .lrodata.* .gnu.linkonce.lr.*)
}
.ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
{
*(.ldata .ldata.* .gnu.linkonce.l.*)
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
. = ALIGN(64 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/* DWARF Extension. */
.debug_macro 0 : { *(.debug_macro) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}
==================================================
échec de la tentative d'ouverture de //usr/local/lib/x86_64-linux-gnu/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/local/lib/x86_64-linux-gnu/libgurobi_c++.a
échec de la tentative d'ouverture de //lib/x86_64-linux-gnu/libgurobi_c++.so
échec de la tentative d'ouverture de //lib/x86_64-linux-gnu/libgurobi_c++.a
échec de la tentative d'ouverture de //usr/lib/x86_64-linux-gnu/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/lib/x86_64-linux-gnu/libgurobi_c++.a
échec de la tentative d'ouverture de //usr/local/lib64/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/local/lib64/libgurobi_c++.a
échec de la tentative d'ouverture de //lib64/libgurobi_c++.so
échec de la tentative d'ouverture de //lib64/libgurobi_c++.a
échec de la tentative d'ouverture de //usr/lib64/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/lib64/libgurobi_c++.a
échec de la tentative d'ouverture de //usr/local/lib/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/local/lib/libgurobi_c++.a
échec de la tentative d'ouverture de //lib/libgurobi_c++.so
échec de la tentative d'ouverture de //lib/libgurobi_c++.a
échec de la tentative d'ouverture de //usr/lib/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/lib/libgurobi_c++.a
échec de la tentative d'ouverture de //usr/x86_64-linux-gnu/lib64/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/x86_64-linux-gnu/lib64/libgurobi_c++.a
échec de la tentative d'ouverture de //usr/x86_64-linux-gnu/lib/libgurobi_c++.so
échec de la tentative d'ouverture de //usr/x86_64-linux-gnu/lib/libgurobi_c++.a
ld : ne peut trouver -lgurobi_c++
Any ideas?

LD_LIBRARY_PATH is the path where the dynamic loader (ld.so and ld-linux.so on Linux, dyld on OS X) looks up libraries. You need this when you run programs that depend on libraries in non-standard paths.
It doesn't necessarily influence where the linker finds libraries. Use the -L flag to specify the search path for ld:
ld -L/opt/gurobi701/linux64/lib -lgurobi_c++ ...

Related

Initialized vs uninitialized global variables, in which part of the RAM are the stored?

The problem is that When I define the arrays like this :
float Data_Set_X[15000];
float Data_Set_Y[15000];
float Data_Set_Z[15000];
I get the RAM overflow error which is: .bss will not fit in region RAM Timer-Blink-Test_CM7 C/C++ Problem
When I initilaze at least one of the arrays or three of them , the error will be disappeared.
float Data_Set_X[15000]={0};
float Data_Set_Y[15000];
float Data_Set_Z[15000];
My variables are global.
In linker script file it is written that:
/* Specify the memory areas */
MEMORY
{
RAM_EXEC (rx) : ORIGIN = 0x24000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x24040000, LENGTH = 256K
}
/* The startup code goes first into RAM_EXEC */
/* The program code and other data goes into RAM_EXEC */
/* Constant data goes into RAM_EXEC */
/* Initialized data sections goes into RAM, load LMA copy after code */
And there is a separated part of the RAM for /* Uninitialized data section */ according to the linker script.
The RAM size is 1MB and around 800KB is accessible for the user. MCU has dual core and I use the M7 Core. this core can access to a 512KB RAM area as it is mentioned in the Linker Script file. the whole size of these three arrays are 180KB
Here is the linker Script file of my Micro Controller
/*
******************************************************************************
**
** File : LinkerScript.ld
**
**
** Abstract : Linker script for STM32H7 series
** 256Kbytes RAM_EXEC and 256Kbytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed as is, without any warranty
** of any kind.
**
*****************************************************************************
** #attention
**
** Copyright (c) 2019 STMicroelectronics.
** All rights reserved.
**
** This software component is licensed by ST under BSD 3-Clause license,
** the "License"; You may not use this file except in compliance with the
** License. You may obtain a copy of the License at:
** opensource.org/licenses/BSD-3-Clause
**
****************************************************************************
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x24080000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200 ; /* required amount of heap */
_Min_Stack_Size = 0x400 ; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM_EXEC (rx) : ORIGIN = 0x24000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x24040000, LENGTH = 256K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into RAM_EXEC */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >RAM_EXEC
/* The program code and other data goes into RAM_EXEC */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >RAM_EXEC
/* Constant data goes into RAM_EXEC */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >RAM_EXEC
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM_EXEC
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >RAM_EXEC
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >RAM_EXEC
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >RAM_EXEC
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >RAM_EXEC
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> RAM_EXEC
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}
Thank you!
Then using this linker script the initialized static storage objects will be stored in the RAM memory section as the .data segment is stored there.
The initial values will be stored in the RAM_EXEC memory section. The startup code will have to copy this data from the RAM_EXEC to RAM.
The problem is that something (probably the debug probe or the bootloader) will have to program the RAM_EXEC memory section first
The not initialized static storage objects will be stored in the RAM memory section as the .bss section is located there. The startup code will have to zero those
The best way is to see what is actually in the memory and where. Generate the .map file to see the exact placement (you can increase the size of the RAM to pass the linking. It will not be the valid executable, but you will be able to generate the .map file)

How to debug cross-compiled QEMU program with GDB?

I'm having trouble debugging a simple program running in QEMU with GDB. GDB seems unable to find where I am in the program (in that it always displays ?? as my current location), and it never hits any breakpoint I set.
In one terminal, I run QEMU:
$ cat add.c
int main() {
int x = 9;
int v = 1;
while (1) {
int q = x + v;
}
return 0;
}
$ riscv64-unknown-elf-gcc add.c -g
$ qemu-system-riscv64 -gdb tcp::1234 -drive file=a.out,format=raw
And in another terminal, I run GDB:
$ riscv64-unknown-elf-gdb a.out
GNU gdb (GDB) 8.2.90.20190228-git
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin17.7.0 --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...
(gdb) target remote :1234
Remote debugging using :1234
0x0000000000000000 in ?? ()
(gdb) list
1 int main() {
2 int x = 9;
3 int v = 1;
4 while (1) {
5 int q = x + v;
6 }
7 return 0;
8 }
(gdb) b main
Breakpoint 1 at 0x1018e: file add.c, line 2.
(gdb) b 5
Breakpoint 2 at 0x1019a: file add.c, line 5.
(gdb) b _start
Breakpoint 3 at 0x10114
(gdb) b 4
Breakpoint 4 at 0x101a8: file add.c, line 4.
(gdb) c
Continuing.
I never hit a breakpoint, even though the program should be looping infinitely. It seems odd that it's displaying 0x0000000000000000 in ?? ()...but maybe that's okay?
What am I doing wrong here? How can I step through this program?
I think you are missing a linker script and some startup code - disclaimer: I am a newcomer to riscv.
You will find a lot of information on those two topics on the Internet, but you basically need to specify where your program will be located in RAM, to establish a stack and initialize the frame pointer:
This is required if you want to be able to call functions and declare automatic C variables like a, b, c in your program.
I used the Windows toolchain from Kendryte for the purpose of this example (the Linux version is available here), and a Windows version of qemu retrieved here.
1) Linker script: the example uses a slightly modified example of the default linker script used by riscv64-unknown-elf-ld:
riscv64-unknown-elf-ld --verbose > riscv64-virt.ld
Edit riscv64-virt.ld, and keep only the lines delimited by:
==================================================
Add a description for the memory layout of the qemu-system-riscv64 virt machine:
OUTPUT_ARCH(riscv)
MEMORY
{
/* qemu-system-risc64 virt machine */
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 128M
}
ENTRY(_start)
Use ORIGIN(RAM) and LENGTH(RAM) instead of hard-coded values, and provide a __stack_top symbol:
PROVIDE (__executable_start = SEGMENT_START("text-segment", ORIGIN(RAM))); . = SEGMENT_START("text-segment", ORIGIN(RAM)) + SIZEOF_HEADERS;
PROVIDE(__stack_top = ORIGIN(RAM) + LENGTH(RAM));
By the way, there are multiple ways of learning the memory layout of a qemu-system target machine, but I usually look at its Device Tree file:
qemu-system-riscv64 -machine virt -machine dumpdtb=riscv64-virt.dtb
dtc -I dtb -O dts -o riscv-virt.dts riscv-virt.dtb
The section describing the memory tells us it starts at 0x80000000:
memory#80000000 {
device_type = "memory";
reg = <0x0 0x80000000 0x0 0x8000000>;
};
riscv64-virt.ld:
/* Script for -z combreloc: combine and sort reloc sections */
/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv",
"elf64-littleriscv")
OUTPUT_ARCH(riscv)
MEMORY
{
/* qemu-system-risc64 virt machine */
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 128M
}
ENTRY(_start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = SEGMENT_START("text-segment", ORIGIN(RAM))); . = SEGMENT_START("text-segment", ORIGIN(RAM)) + SIZEOF_HEADERS;
PROVIDE(__stack_top = ORIGIN(RAM) + LENGTH(RAM));
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
*(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
*(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
*(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
.rela.plt :
{
*(.rela.plt)
}
.init :
{
KEEP (*(SORT_NONE(.init)))
}
.plt : { *(.plt) }
.iplt : { *(.iplt) }
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
}
.fini :
{
KEEP (*(SORT_NONE(.fini)))
}
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.sdata2 :
{
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
}
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
.eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
.gcc_except_table.*) }
.gnu_extab : ONLY_IF_RO { *(.gnu_extab*) }
/* These sections are generated by the Sun/Oracle C++ compiler. */
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
.exception_ranges*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
/* Thread Local Storage sections */
.tdata :
{
PROVIDE_HIDDEN (__tdata_start = .);
*(.tdata .tdata.* .gnu.linkonce.td.*)
}
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
. = DATA_SEGMENT_RELRO_END (0, .);
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
__global_pointer$ = . + 0x800;
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
_edata = .; PROVIDE (edata = .);
. = .;
__bss_start = .;
.sbss :
{
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
}
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
. = ALIGN(64 / 8);
. = SEGMENT_START("ldata-segment", .);
. = ALIGN(64 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/* DWARF Extension. */
.debug_macro 0 : { *(.debug_macro) }
.debug_addr 0 : { *(.debug_addr) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}
2) startup.s: (credits: here and here).
.section .init, "ax"
.global _start
_start:
.cfi_startproc
.cfi_undefined ra
.option push
.option norelax
la gp, __global_pointer$
.option pop
la sp, __stack_top
add s0, sp, zero
jal zero, main
.cfi_endproc
.end
add.c: (your code)
int main() {
int a = 4;
int b = 12;
while (1) {
int c = a + b;
}
return 0;
}
3) compiling/linking, and creating a listing:
riscv64-unknown-elf-gcc -g -ffreestanding -O0 -Wl,--gc-sections -nostartfiles -nostdlib -nodefaultlibs -Wl,-T,riscv64-virt.ld -o add.elf startup.s add.c
riscv64-unknown-elf-objdump -D add.elf > add.objdump
4) starting qemu in a console:
qemu-system-riscv64 -machine virt -m 128M -gdb tcp::1234,ipv4 -kernel add.elf
I am not sure that the qemu options you were using: -drive file=a.out,format=raw
are correct, and I think they are not, but I did not spend time checking, and used the options I am usually using: -kernel add.elf
4) starting gdb in another console (I am using here a GDB I compiled with TUI support for mingw64 for my own convenience).
riscv64-elf-gdb --tui add.elf
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
main () at add.c:5
(gdb) p a
$1 = 4
(gdb) p b
$2 = 12
(gdb) p c
$3 = 16
(gdb)
This may have been a little bit long, but I hope this will help.
Please note that the startup code is good enough for your code, but some important initializations are missing, such as copying the data section from flash to RAM (not relevant here), and clearing the .bss section.
Using riscv-gnu-toolchain built with glibc is a much simpler method to debug riscv programs unless you are debugging some system-level program where you must use riscv64-unknown-elf-gcc instead of riscv64-unknown-linux-gnu-gcc. For a simple program like your add.c, using user-space qemu-riscv and glibc riscv-gnu-toolchain can save you a lot of trouble. (One can install these tools following the commands listed at the bottom)
By the time I am writing this answer, there are two different versions of the riscv toolchain: one built with newlib which provides riscv64-unknown-elf-* and another with glibc which provides riscv64-unknown-linux-gnu-*. There are also two versions of qemu: qemu-system-riscv64 for debugging kernels or bare-metal programs and qemu-riscv64 for debugging user-space programs compiled with libc.
For simple programs like add.c, one may debug it with the second type of the toolchain:
Compile: riscv64-unknown-linux-gnu-gcc add.c -o add -g
Run: qemu-riscv64 -L /opt/riscv/sysroot/ -g 1234 add -S
Then launch GDB: riscv64-unknown-linux-gnu-gdb add
Inside GDB:
target remote:1234
b main
c
And the program should break at the main entrance.
(Another option is to statically link the program: riscv64-unknown-linux-gnu-gcc add.c -o add -g -static and then qemu-riscv64 -g 1234 add -S should work as well)
I did not find many documents mentioning user-space riscv qemu. All I found were articles talking about how to use qemu to debug OS kernels with RISC-V ISA. For the convenience of other newcomers to riscv like me, I will show in the following how to build the mentioned tools.
qemu (https://www.qemu.org/download/#source)
wget https://download.qemu.org/qemu-5.0.0.tar.xz
tar xvJf qemu-5.0.0.tar.xz
cd qemu-5.0.0 # higher versions might have problems
./configure --target-list=riscv64-linux-user,riscv64-softmmu
make -j$(nproc)
sudo make install
, where riscv64-softmmu gives you qemu-system-riscv64 and riscv64-linux-user gives you qemu-riscv64.
riscv-gnu-toolchain (https://github.com/riscv/riscv-gnu-toolchain.git)
git clone https://github.com/riscv/riscv-gnu-toolchain.git
sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev libncurses5-dev
./configure --prefix=/opt/riscv --enable-multilib
sudo make linux # this provides you the glibc set of tools (the ones we need here)
sudo make # this provides you the newlib set of tools

Why can't GCC cross compiler find all libraries?

Why does it look for libgcc in the library search paths, but not for the crt*.o libraries (scroll down in the second code block below)? Also, why is it looking in /lib and /usr/lib under the sysroot, but not in /tmptools/lib under the sysroot (which is the only path that I actually want it to look in)? This is how the cross compiler was configured:
../binutils-2.26/configure --prefix="$LFS_CROSSTOOLCHAIN" --build=$LFS_BUILD_ARCH --host=$LFS_BUILD_ARCH --target=$LFS_TARGET_ARCH --with-lib-path="/tmptools/lib" --disable-multilib --disable-multiarch --disable-rpath --disable-nls --with-sysroot="$LFS_SYSROOT"
../gcc-6.1.0/configure --prefix="$LFS_CROSSTOOLCHAIN" --build=$LFS_BUILD_ARCH --host=$LFS_BUILD_ARCH --target=$LFS_TARGET_ARCH --disable-bootstrap --with-newlib --without-headers --with-local-prefix="/tmptools" --with-native-system-header-dir="/tmptools/include" --with-lib-path="/tmptools/lib" --disable-multilib --disable-multiarch --disable-rpath --enable-languages=c,c++ --disable-nls --with-sysroot="$LFS_SYSROOT"
Where LFS_CROSSTOOLCHAIN=/home/main/lfs/3/crosstools and LFS_SYSROOT=/home/main/lfs/3/root.
This is example output:
$ 3/crosstools/bin/x86_64-lfs-linux-gnu-gcc -print-sysroot
/home/main/lfs/3/root
$ 3/crosstools/bin/x86_64-lfs-linux-gnu-ld -print-sysroot
/home/main/lfs/3/root
$ 3/crosstools/bin/x86_64-lfs-linux-gnu-gcc -Wl,--verbose test.c
GNU ld (GNU Binutils) 2.26.20160125
Supported emulations:
elf_x86_64
elf32_x86_64
elf_i386
elf_iamcu
i386linux
elf_l1om
elf_k1om
using internal linker script:
==================================================
/* Script for -z combreloc: combine and sort reloc sections */
/* Copyright (C) 2014-2015 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
"elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SEARCH_DIR("=/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib64"); SEARCH_DIR("/tmptools/lib"); SEARCH_DIR("=/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib");
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
*(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*)
*(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*)
*(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*)
*(.rela.ifunc)
}
.rela.plt :
{
*(.rela.plt)
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
.init :
{
KEEP (*(SORT_NONE(.init)))
}
.plt : { *(.plt) *(.iplt) }
.plt.got : { *(.plt.got) }
.plt.bnd : { *(.plt.bnd) }
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
}
.fini :
{
KEEP (*(SORT_NONE(.fini)))
}
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
.gcc_except_table.*) }
.gnu_extab : ONLY_IF_RO { *(.gnu_extab*) }
/* These sections are generated by the Sun/Oracle C++ compiler. */
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
.exception_ranges*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array ))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array ))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
.got : { *(.got) *(.igot) }
. = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
.got.plt : { *(.got.plt) *(.igot.plt) }
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
. = .;
__bss_start = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
.lbss :
{
*(.dynlbss)
*(.lbss .lbss.* .gnu.linkonce.lb.*)
*(LARGE_COMMON)
}
. = ALIGN(64 / 8);
. = SEGMENT_START("ldata-segment", .);
.lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
{
*(.lrodata .lrodata.* .gnu.linkonce.lr.*)
}
.ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
{
*(.ldata .ldata.* .gnu.linkonce.l.*)
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
. = ALIGN(64 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/* DWARF Extension. */
.debug_macro 0 : { *(.debug_macro) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}
==================================================
attempt to open crt1.o failed
attempt to open crti.o failed
attempt to open crtbegin.o failed
attempt to open /tmp/ccLVBgXQ.o succeeded
/tmp/ccLVBgXQ.o
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc.a failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc.a failed
attempt to open /home/main/lfs/3/root/lib/libgcc.so failed
attempt to open /home/main/lfs/3/root/lib/libgcc.a succeeded
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc_s.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc_s.a failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/usr/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/usr/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib64/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib64/libgcc_s.a failed
attempt to open /tmptools/lib/libgcc_s.so failed
attempt to open /tmptools/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libc.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libc.a failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libc.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libc.a failed
attempt to open /home/main/lfs/3/root/lib/libc.so failed
attempt to open /home/main/lfs/3/root/lib/libc.a failed
attempt to open /home/main/lfs/3/root/usr/lib/libc.so failed
attempt to open /home/main/lfs/3/root/usr/lib/libc.a failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib64/libc.so failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib64/libc.a failed
attempt to open /tmptools/lib/libc.so failed
attempt to open /tmptools/lib/libc.a failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib/libc.so failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib/libc.a failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc.a failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc.a failed
attempt to open /home/main/lfs/3/root/lib/libgcc.so failed
attempt to open /home/main/lfs/3/root/lib/libgcc.a succeeded
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc_s.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/libgcc_s.a failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/usr/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/usr/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib64/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib64/libgcc_s.a failed
attempt to open /tmptools/lib/libgcc_s.so failed
attempt to open /tmptools/lib/libgcc_s.a failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib/libgcc_s.so failed
attempt to open /home/main/lfs/3/root/home/main/lfs/3/crosstools/x86_64-lfs-linux-gnu/lib/libgcc_s.a failed
attempt to open crtend.o failed
attempt to open crtn.o failed
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crtbegin.o: No such file or directory
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find -lgcc_s
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find -lc
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find -lgcc_s
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crtend.o: No such file or directory
/home/main/lfs/3/crosstools/lib/gcc/x86_64-lfs-linux-gnu/6.1.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
When I built a GCC toolchain for cross-compiling ARM, I used this helpful tutorial. The errors you are seeing look similar to what happens if you skip these commands:
make -j4 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross/aarch64-linux/lib
Which are part of a sequence of commands used to provide the headers for GLIBC to the cross-compiler.
mkdir -p build-glibc
cd build-glibc
../glibc-2.20/configure --prefix=/opt/cross/aarch64-linux --build=$MACHTYPE
--host=aarch64-linux --target=aarch64-linux \
--with-headers=/opt/cross/aarch64-linux/include \
--disable-multilib libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make -j4 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross/aarch64-linux/lib \
aarch64-linux-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o \
/opt/cross/aarch64-linux/lib/libc.so
touch /opt/cross/aarch64-linux/include/gnu/stubs.h
cd ..
It's unclear if the GLIBC headers are already in your sysroot directory, but I would start by checking to make sure those files exist. You may need to build the GLIBC headers if you are not getting them some other way.

Search Directories for ld passed via gcc and loaded libraries

I am trying to crosscompile a simple c program using gcc. In my case it is a small gtk2 application:
#include <gtk/gtk.h>
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
return 0;
}
I want to link it against gtk-x11-2.0, which contains the gtk_init function. When passing via -L he explicit path to the rootsys of the remote system and analyzing the output of the linker via
gcc ... -Wl,-verbose ... ,
I can see that the path is not listed as
SEARCH_DIR("= ...")
and results in a "undefined reference to gtk_init..."
but in the end of the output it shows that the library has been loaded at the right path.
See complete linker script listing:
16:01:37 **** Incremental Build of configuration Default for project
SysrootTest ****
make all
#arm-linux-gnueabihf-g++ -v -g -Wall -mtune=cortex-a8 -march=armv7-a --sysroot=/home/dominik/bbbroot -o simple -L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -Xlinker -rpath-link=/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -I/home/dominik/bbbroot/usr/include/gtk-2.0 -I/home/dominik/bbbroot/usr/include/pango-1.0 -I/home/dominik/bbbroot/usr/include/atk-1.0 -I/home/dominik/bbbroot/usr/include/cairo -I/home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0 -I/home/dominik/bbbroot/usr/include/glib-2.0 -I/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -lgtk-x11-2.0 simple.c
arm-linux-gnueabihf-g++ -v -g -Wall -mtune=cortex-a8 -march=armv7-a --sysroot=/home/dominik/bbbroot -o simple -L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -Xlinker -rpath-link=/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -Wl,-verbose,-L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -I/home/dominik/bbbroot/usr/include/gtk-2.0 -I/home/dominik/bbbroot/usr/include/pango-1.0 -I/home/dominik/bbbroot/usr/include/atk-1.0 -I/home/dominik/bbbroot/usr/include/cairo -I/home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0 -I/home/dominik/bbbroot/usr/include/glib-2.0 -I/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -lgtk-x11-2.0 simple.c
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.2-16ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabihf/include/c++/4.8.2 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-armhf-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-armhf-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include
Thread model: posix
gcc version 4.8.2 (Ubuntu/Linaro 4.8.2-16ubuntu4)
COLLECT_GCC_OPTIONS='-v' '-g' '-Wall' '-mtune=cortex-a8' '-march=armv7-a' '-o' 'simple' '-L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf' '-I' '/home/dominik/bbbroot/usr/include/gtk-2.0' '-I' '/home/dominik/bbbroot/usr/include/pango-1.0' '-I' '/home/dominik/bbbroot/usr/include/atk-1.0' '-I' '/home/dominik/bbbroot/usr/include/cairo' '-I' '/home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0' '-I' '/home/dominik/bbbroot/usr/include/glib-2.0' '-I' '/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include' '-I' '/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include' '-shared-libgcc' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/cc1plus -quiet -v -I /home/dominik/bbbroot/usr/include/gtk-2.0 -I /home/dominik/bbbroot/usr/include/pango-1.0 -I /home/dominik/bbbroot/usr/include/atk-1.0 -I /home/dominik/bbbroot/usr/include/cairo -I /home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0 -I /home/dominik/bbbroot/usr/include/glib-2.0 -I /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -imultiarch arm-linux-gnueabihf -isysroot /home/dominik/bbbroot -D_GNU_SOURCE simple.c -quiet -dumpbase simple.c -mtune=cortex-a8 -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -mthumb -mtls-dialect=gnu -auxbase simple -g -Wall -version -fstack-protector -Wformat -Wformat-security -o /tmp/ccjGniT3.s
GNU C++ (Ubuntu/Linaro 4.8.2-16ubuntu4) version 4.8.2 (arm-linux-gnueabihf)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/home/dominik/bbbroot/usr/arm-linux-gnueabihf/include/c++/4.8.2"
ignoring nonexistent directory "/home/dominik/bbbroot/usr/arm-linux-gnueabihf/include/c++/4.8.2/arm-linux-gnueabihf"
ignoring nonexistent directory "/home/dominik/bbbroot/usr/arm-linux-gnueabihf/include/c++/4.8.2/backward"
ignoring nonexistent directory "/home/dominik/bbbroot/usr/local/include/arm-linux-gnueabihf"
#include "..." search starts here:
#include <...> search starts here:
/home/dominik/bbbroot/usr/include/gtk-2.0
/home/dominik/bbbroot/usr/include/pango-1.0
/home/dominik/bbbroot/usr/include/atk-1.0
/home/dominik/bbbroot/usr/include/cairo
/home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0
/home/dominik/bbbroot/usr/include/glib-2.0
/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include
/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include-fixed
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/include
/home/dominik/bbbroot/usr/include/arm-linux-gnueabihf
/home/dominik/bbbroot/usr/include
End of search list.
GNU C++ (Ubuntu/Linaro 4.8.2-16ubuntu4) version 4.8.2 (arm-linux-gnueabihf)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5864e76821369f09a9f341580a4c0155
COLLECT_GCC_OPTIONS='-v' '-g' '-Wall' '-mtune=cortex-a8' '-march=armv7-a' '-o' 'simple' '-L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf' '-I' '/home/dominik/bbbroot/usr/include/gtk-2.0' '-I' '/home/dominik/bbbroot/usr/include/pango-1.0' '-I' '/home/dominik/bbbroot/usr/include/atk-1.0' '-I' '/home/dominik/bbbroot/usr/include/cairo' '-I' '/home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0' '-I' '/home/dominik/bbbroot/usr/include/glib-2.0' '-I' '/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include' '-I' '/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include' '-shared-libgcc' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/as -v -I /home/dominik/bbbroot/usr/include/gtk-2.0 -I /home/dominik/bbbroot/usr/include/pango-1.0 -I /home/dominik/bbbroot/usr/include/atk-1.0 -I /home/dominik/bbbroot/usr/include/cairo -I /home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0 -I /home/dominik/bbbroot/usr/include/glib-2.0 -I /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -meabi=5 -o /tmp/cc4sA1i3.o /tmp/ccjGniT3.s
Die GNU-Assembler-Version 2.24 (arm-linux-gnueabihf) benutzt die BFD-Version (GNU Binutils for Ubuntu) 2.24
COMPILER_PATH=/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/:/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/:/usr/lib/gcc-cross/arm-linux-gnueabihf/:/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/:/usr/lib/gcc-cross/arm-linux-gnueabihf/:/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/
LIBRARY_PATH=/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/:/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/:/home/dominik/bbbroot/lib/arm-linux-gnueabihf/:/home/dominik/bbbroot/lib/../lib/:/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/:/home/dominik/bbbroot/usr/lib/../lib/:/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/:/home/dominik/bbbroot/lib/:/home/dominik/bbbroot/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-g' '-Wall' '-mtune=cortex-a8' '-march=armv7-a' '-o' 'simple' '-L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf' '-I' '/home/dominik/bbbroot/usr/include/gtk-2.0' '-I' '/home/dominik/bbbroot/usr/include/pango-1.0' '-I' '/home/dominik/bbbroot/usr/include/atk-1.0' '-I' '/home/dominik/bbbroot/usr/include/cairo' '-I' '/home/dominik/bbbroot/usr/include/gdk-pixbuf-2.0' '-I' '/home/dominik/bbbroot/usr/include/glib-2.0' '-I' '/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include' '-I' '/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/gtk-2.0/include' '-shared-libgcc' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/collect2 --sysroot=/home/dominik/bbbroot --build-id --eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X --hash-style=gnu --as-needed -m armelf_linux_eabi -z relro -o simple /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crt1.o /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crti.o /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/crtbegin.o -L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -L/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8 -L/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib -L/home/dominik/bbbroot/lib/arm-linux-gnueabihf -L/home/dominik/bbbroot/lib/../lib -L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -L/home/dominik/bbbroot/usr/lib/../lib -L/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib -L/home/dominik/bbbroot/lib -L/home/dominik/bbbroot/usr/lib -rpath-link=/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -verbose -L/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf -lgtk-x11-2.0 /tmp/cc4sA1i3.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/crtend.o /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crtn.o
GNU ld (GNU Binutils for Ubuntu) 2.24
Unterstützte Emulationen:
armelf_linux_eabi
armelfb_linux_eabi
using internal linker script:
==================================================
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
"elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
/tmp/cc4sA1i3.o: In Funktion `main':
SEARCH_DIR("=/usr/local/lib/arm-linux-gnueabihf"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib/arm-linux-gnueabihf"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib/arm-linux-gnueabihf"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("/usr/arm-linux-gnueabihf/lib");
/home/dominik/workspaces/Mars/Beaglebone/SysrootTest//simple.c:23: Nicht definierter Verweis auf `gtk_init'
collect2: error: ld returned 1 exit status
SECTIONS
make: *** [main] Fehler 1
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x00008000)); . = SEGMENT_START("text-segment", 0x00008000) + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
PROVIDE_HIDDEN (__rel_iplt_start = .);
*(.rel.iplt)
PROVIDE_HIDDEN (__rel_iplt_end = .);
}
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
.rel.plt :
{
*(.rel.plt)
}
.rela.plt :
{
*(.rela.plt)
}
.init :
{
KEEP (*(SORT_NONE(.init)))
}
.plt : { *(.plt) }
.iplt : { *(.iplt) }
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
}
.fini :
{
KEEP (*(SORT_NONE(.fini)))
}
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
PROVIDE_HIDDEN (__exidx_start = .);
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
PROVIDE_HIDDEN (__exidx_end = .);
.eh_frame_hdr : { *(.eh_frame_hdr) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
.gcc_except_table.*) }
/* These sections are generated by the Sun/Oracle C++ compiler. */
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
.exception_ranges*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array ))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array ))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
. = DATA_SEGMENT_RELRO_END (0, .);
.got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
.data :
{
PROVIDE (__data_start = .);
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
. = .;
__bss_start = .;
__bss_start__ = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
_bss_end__ = . ; __bss_end__ = . ;
. = ALIGN(32 / 8);
. = SEGMENT_START("ldata-segment", .);
. = ALIGN(32 / 8);
__end__ = . ;
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/* DWARF Extension. */
.debug_macro 0 : { *(.debug_macro) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}
==================================================
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crt1.o zu öffnen, war erfolgreich
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crt1.o
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crti.o zu öffnen, war erfolgreich
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crti.o
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/crtbegin.o zu öffnen, war erfolgreich
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/crtbegin.o
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgtk-x11-2.0.so zu öffnen, war erfolgreich
-lgtk-x11-2.0 (/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgtk-x11-2.0.so)
Der Versuch, /tmp/cc4sA1i3.o zu öffnen, war erfolgreich
/tmp/cc4sA1i3.o
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libstdc++.so zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libstdc++.a zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libstdc++.so zu öffnen, war erfolgreich
-lstdc++ (/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libstdc++.so)
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libm.so zu öffnen, war erfolgreich
-lm (/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libm.so)
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc_s.so zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc_s.a zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so zu öffnen, war erfolgreich
Skriptdatei /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so geöffnet
Skriptdatei /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so geöffnet
Der Versuch, libgcc_s.so.1 zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc_s.so.1 zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so.1 zu öffnen, war erfolgreich
libgcc_s.so.1 (/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so.1)
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.a zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a zu öffnen, war erfolgreich
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.a zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a zu öffnen, war erfolgreich
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libc.so zu öffnen, war erfolgreich
Skriptdatei /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libc.so geöffnet
Skriptdatei /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libc.so geöffnet
Der Versuch, /home/dominik/bbbroot/lib/arm-linux-gnueabihf/libc.so.6 zu öffnen, war erfolgreich
/lib/arm-linux-gnueabihf/libc.so.6 (/home/dominik/bbbroot/lib/arm-linux-gnueabihf/libc.so.6)
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libc_nonshared.a zu öffnen, war erfolgreich
(/home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libc_nonshared.a)elf-init.oS
Der Versuch, /home/dominik/bbbroot/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 zu öffnen, war erfolgreich
/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 (/home/dominik/bbbroot/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3)
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc_s.so zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc_s.a zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so zu öffnen, war erfolgreich
Skriptdatei /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so geöffnet
Skriptdatei /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so geöffnet
Der Versuch, libgcc_s.so.1 zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc_s.so.1 zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so.1 zu öffnen, war erfolgreich
libgcc_s.so.1 (/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc_s.so.1)
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.a zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a zu öffnen, war erfolgreich
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /home/dominik/bbbroot/usr/lib/arm-linux-gnueabihf/libgcc.a zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.so zu öffnen, ist fehlgeschlagen
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/libgcc.a zu öffnen, war erfolgreich
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/crtend.o zu öffnen, war erfolgreich
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/crtend.o
Der Versuch, /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crtn.o zu öffnen, war erfolgreich
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/lib/../lib/crtn.o
ld-linux-armhf.so.3 needed by /home/dominik/bbbroot/lib/arm-linux-gnueabihf/libc.so.6
found ld-linux-armhf.so.3 at /home/dominik/bbbroot/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3
16:01:40 Build Finished (took 2s.415ms)
what am I doing wrong?

UART on SAM4SxPLAINED

UART on SAM4SxPLAINED
Hello,
I have a program which (almost) works !
The characters are transmitted but they are not still the ones hoped.
Who can correct?
Thank you for everything.
Greetings.
Voici le code :
#include "sam.h"
// Fréquence d'horloge
#define MCLK CHIP_FREQ_MAINCK_RC_4MHZ
// Configure UART
#define BAUD 115200
#define PARITY UART_MR_PAR_NO
//#define PARITY UART_MR_PAR_EVEN
// Définitions pour PA9 comme RX_UART0 et PA10 comme TX_UART0 (Périphérique A).
#define RXTX_PIO PIOA
#define RX_PIN PIO_PA9
#define TX_PIN PIO_PA10
#define UART UART0
#define UART_PID ID_UART0
#define RXTX_IRQn PIOA_IRQn
#define UART_IRQn UART0_IRQn
//prototype pour les fonctions. On ne veut pas faire un .h pour ça !
void hardware_init( void ) ;
void hardware_init( void )
{
//pour utiliser RX_UART et TX_UART.
PMC->PMC_PCER0 = (1 << UART_PID) ;
RXTX_PIO->PIO_IDR |= RX_PIN | TX_PIN ;
// Sélectionne le périphérique A
RXTX_PIO->PIO_ABCDSR[0] &= ~(RX_PIN | TX_PIN) ;
RXTX_PIO->PIO_ABCDSR[1] &= ~(RX_PIN | TX_PIN) ;
RXTX_PIO->PIO_PDR = (RX_PIN | TX_PIN) ;
//Configure UART
UART->UART_BRGR= MCLK / (BAUD * 16) ;
UART->UART_CR = UART_CR_TXEN | UART_CR_RXEN ;
UART->UART_IER = UART_IER_RXRDY ;
// Active les interruptions sur UART;
NVIC_EnableIRQ( UART_IRQn ) ;
// Configure Systick pour un déclenchement chaque milliseconde
SysTick_Config( SystemCoreClock/1000UL ) ;
NVIC_EnableIRQ( SysTick_IRQn ) ;
}
// Variable globale pour compter les tics
static uint32_t ul_tickcount=0 ;
// Variable globale pour UART_Handler
static int32_t tr ;
static uint32_t j = 0 ;
static char chaine[] = "Bonjour UART0 " ;
static uint8_t nb_car = 14 ; //nombre de caractères de chaine
void SysTick_Handler( void )
{
ul_tickcount++ ;
// envoie un caractère toutes les secondes (ie 1000ms)
if ( ul_tickcount == 1000)
{
if (j == nb_car)
{
j=0;
}
while(!(UART->UART_SR & UART_SR_TXRDY)) ;
UART->UART_THR = chaine[j] ;
j++ ;
ul_tickcount = 0 ;
}
}
void UART0_Handler( void )
{
if (UART->UART_SR & UART_SR_RXRDY)
{
tr = UART->UART_RHR ;
while(!(UART->UART_SR & UART_SR_TXRDY));
UART->UART_THR = tr - 1 ;
}
}
int main (void)
{
hardware_init() ;
while ( 1 )
{
}
}