linker-scripts

Linker Script Does Not Skip Bytes As Expected

↘锁芯ラ 提交于 2019-12-07 19:01:47
问题 So, I have this assembly file, which I assemble with GNU as and link with GNU ld using a linker script. Linker script ( boot.ld ): INPUT(boot.o) OUTPUT(boot.out) ENTRY(boot_start) SECTIONS { . = 0x7c00; .text : { *(.text) } .data : { *(.data) } . = 0x7dfe; .boot_end : { *(.boot_end) } } As you see I try to make the file exactly 512 bytes as needed for a bootloader by doing . = 0x7cdfe . .boot_end contains the boot signature and thus fills up the remaining two bytes. I create the bootloader as

Put gcc libs .data in specific section?

只谈情不闲聊 提交于 2019-12-06 01:47:39
I'm trying to switch to the GNU GCC compiler for our embedded system, but I'm having trouble linking the project as the memory layout of our chip is split: RAM section 1: 0x10000-0x12FFF RAM section 2: 0x18000-0x1BFFF The data from our project can fit in section 1, but the data linked from the gcc libs doesn't. Map file extract: .data 0x00012974 0x3c4 c:/tools/gnucr16_v1.1.3-elf/cr16-elf/bin/../lib/gcc/cr16-elf/4.5.1-GNUCR16_v1.1.3/../../../../cr16-elf/lib\libc.a(lib_a-impure.o) 0x00012974 _impure_ptr .data 0x00012d7c 0x410 c:/tools/gnucr16_v1.1.3-elf/cr16-elf/bin/../lib/gcc/cr16-elf/4.5.1

Why does GCC put calls to constructors of global instances into different sections (depending on the target)?

折月煮酒 提交于 2019-12-06 01:22:40
问题 I have some simple declarations of a global instances with non-empty constructors. These constructors are called during startup automatically. I am cross-compiling C++ on Linux to different microcontroller targets. As for arm-none-eabi-gcc-4.8.4 rx-elf-gcc-4.8-GNURX_v14.03 (GCC 4.8.3) calls to constructors are put into the .init_array section. The map file looks like this: .init_array 0x00007cb8 0x4 libmotor.o .init_array 0x00007cbc 0x4 libaudio.o As for mips-elf-gcc-4.8.2 avr-gcc-4.8.1

Offset of global const variable in executable

回眸只為那壹抹淺笑 提交于 2019-12-04 11:59:27
问题 Would like to have an executable save its state by modifying its own global constants. Just for the kicks of having a totally self-contained executable. A few solutions/hacks that come to mind: Use libelf and have the program parse itself to find the offset. Add a specific marker and just search for it in the executable file. I guess this might even be somewhat cross-platform? Use object dumping utils to determine the address in the executable file. This probably needs to be always done as a

ALIGN in Linker Scripts

﹥>﹥吖頭↗ 提交于 2019-12-03 05:28:54
What does the ALIGN keyword do in linker scripts? I read many tutorials about linker scripts but I cant understand what really ALIGN do. Can any one explain it simply. Thanks! A typical usage is . = ALIGN(8); This means: insert padding bytes until current location becomes aligned on 8-byte boundary. That is: while ((current_location & 7) != 0) *current_location++ = padding_value; The ALIGN() instructions tell the linker that section(bss, text) shoul be this much aligned. For a typical idea, you can take a look here e.g. //.data is aligned by word size on the 32-bit architecture and direct it

Why does GNU ld include a section that does not appear in the linker script?

微笑、不失礼 提交于 2019-12-02 17:02:20
问题 I'm trying to create a minimal C example on a boot sector for educational purposes. However, I noticed that my example was not being recognized as a boot sector because he magic 0x55aa bytes were not present as the 511th and 512th bytes. Then, I investigated further, and it seems that this is because the .eh_frame section was getting included in the image, even though it was never mentioned in the linker script. Why is that? The exact setup is present here and reproduced below build.sh: as

rename a symbol using a linker script

我们两清 提交于 2019-12-02 03:36:16
问题 Is it possible to use a linker script or mapfile to rename a symbol? I'm trying to adapt some code written in a mix of C++ and Fortran so that it will work with more than one Fortran compiler - on Linux. It is currently written for the Solaris Studio compiler with the option for case-sensitivity enabled. I'd like to handle variations in Fortran symbol name mangling automatically (such as from the Makefile). It does appear to be possible to create aliases so, a linker script containing: C

Linker script .relocate section's first symbol, _srelocate, is incorrect (GCC Bug?)

别来无恙 提交于 2019-12-02 02:01:21
问题 Problem My problem is that when I use the following script which is intended to place the Code into RAM the relocate section gets filled with bogus data. My question is: Why is the _srelocate symbol 4 bytes greater than the _etext symbol? Shouldn't they be the same? Also, if the answer to 1. is NO, shouldn't I be copying from _etext + 4 to _srelocate ? Background and relevant code I'm working with an Atmel ATSAM3N4X series processor (an ARM Cortex M3) and would like a little help with my

rename a symbol using a linker script

别来无恙 提交于 2019-12-02 01:55:56
Is it possible to use a linker script or mapfile to rename a symbol? I'm trying to adapt some code written in a mix of C++ and Fortran so that it will work with more than one Fortran compiler - on Linux. It is currently written for the Solaris Studio compiler with the option for case-sensitivity enabled. I'd like to handle variations in Fortran symbol name mangling automatically (such as from the Makefile). It does appear to be possible to create aliases so, a linker script containing: C_Function_ = c_function; will sort-of work. Unfortunately, adding the -T option to reference this script

Linker script .relocate section's first symbol, _srelocate, is incorrect (GCC Bug?)

社会主义新天地 提交于 2019-12-02 00:27:25
Problem My problem is that when I use the following script which is intended to place the Code into RAM the relocate section gets filled with bogus data. My question is: Why is the _srelocate symbol 4 bytes greater than the _etext symbol? Shouldn't they be the same? Also, if the answer to 1. is NO, shouldn't I be copying from _etext + 4 to _srelocate ? Background and relevant code I'm working with an Atmel ATSAM3N4X series processor (an ARM Cortex M3) and would like a little help with my linker script and .relocate section initialization. The reason for this is that the _etext symbol is 4