binutils

Why do STM32 gcc linker scripts automatically discard all input sections from these standard libraries: libc.a, libm.a, libgcc.a?

情到浓时终转凉″ 提交于 2019-12-01 10:48:34
From the bottom of any auto-generated STM32CubeMx-generated linker script: /* Remove information from the standard libraries */ /DISCARD/ : { libc.a ( * ) libm.a ( * ) libgcc.a ( * ) } From the GNU Binutils ld (linker script) manual, 3.6.7 Output Section Discarding : The special output section name ‘/DISCARD/’ may be used to discard input sections. Any input sections which are assigned to an output section named ‘/DISCARD/’ are not included in the output file. What do these 3 input object files contain, and why do we discard everything (all input sections) from them? Other STM32 linker script

placing static library answer in the beginning of flash section

余生长醉 提交于 2019-12-01 08:36:02
I'm using atmelstudio to compile a firmware image and want to place the functions from static libraries (including the gnu's libc.a & libgcc.a) in the beginning of the .text section followed .text belong to my project source code. Right now what happen is the other way around. This is my linker script . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) *(.text .text.* .gnu.linkonce.t.*) <-- my functions and functions from static libraries are within this rule *(.glue_7t) *(.glue_7) *(.rodata .rodata* .gnu.linkonce.r.*) *(.ARM.extab* .gnu.linkonce.armextab.*) The star in *(.text) , means to

placing static library answer in the beginning of flash section

独自空忆成欢 提交于 2019-12-01 06:34:25
问题 I'm using atmelstudio to compile a firmware image and want to place the functions from static libraries (including the gnu's libc.a & libgcc.a) in the beginning of the .text section followed .text belong to my project source code. Right now what happen is the other way around. This is my linker script . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) *(.text .text.* .gnu.linkonce.t.*) <-- my functions and functions from static libraries are within this rule *(.glue_7t) *(.glue_7) *(

How to find global static initializations

我与影子孤独终老i 提交于 2019-11-30 21:52:13
I just read this excellent article: http://neugierig.org/software/chromium/notes/2011/08/static-initializers.html and then I tried: https://gcc.gnu.org/onlinedocs/gccint/Initialization.html What it says about finding initializers does not work for me though. The .ctors section is not available, but I could find .init_array (see also Can't find .dtors and .ctors in binary ). But how do I interpret the output? I mean, summing up the size of the pages can also be handled by the size command and its .bss column - or am I missing something? Furthermore, nm does not report any *_GLOBAL__I_* symbols,

How to find global static initializations

Deadly 提交于 2019-11-30 17:42:42
问题 I just read this excellent article: http://neugierig.org/software/chromium/notes/2011/08/static-initializers.html and then I tried: https://gcc.gnu.org/onlinedocs/gccint/Initialization.html What it says about finding initializers does not work for me though. The .ctors section is not available, but I could find .init_array (see also Can't find .dtors and .ctors in binary). But how do I interpret the output? I mean, summing up the size of the pages can also be handled by the size command and

ELF Dynamic loader symbol lookup ordering

送分小仙女□ 提交于 2019-11-30 13:34:13
What is the search order for symbol lookup when resolving dynamic relocations? When resolving symbols for a shared library does the loader first search in the 'main executable' (to let the main executable override definitions...) or what? Per my understanding, each executable object has its own "lookup scope": The main executable is usually the first object in the "global" lookup scope. This means that symbols defined in the main executable would override those in dependent shared libraries. Shared objects that are added using the LD_PRELOAD facility are added to the global lookup scope, right

ELF Dynamic loader symbol lookup ordering

喜欢而已 提交于 2019-11-29 18:55:46
问题 What is the search order for symbol lookup when resolving dynamic relocations? When resolving symbols for a shared library does the loader first search in the 'main executable' (to let the main executable override definitions...) or what? 回答1: Per my understanding, each executable object has its own "lookup scope": The main executable is usually the first object in the "global" lookup scope. This means that symbols defined in the main executable would override those in dependent shared

How to determine which command line options gcc passes to ld by default?

萝らか妹 提交于 2019-11-29 14:24:59
问题 Consider the hello world C program: hello.c : #include "stdio.h" int main() { printf("Hello, World!\n"); } If I call: $ gcc -c hello.c -o hello.o It will produce an ELF Relocatable File hello.o If I then call: $ gcc hello.o -o hello [1] It will link hello.o with ld and produce an ELF Executable File hello However if I call ld directly [2] instead of [1] : $ ld hello.o -o hello [2] I get these errors: /usr/bin/ld.bfd.real: warning: cannot find entry symbol _start test.c:(.text+0xa): undefined

Requirements to use flto

笑着哭i 提交于 2019-11-29 09:31:26
If I want to compile my project with -flto is it enough to have built gcc with --enable-gold or do I also need to build gold and replace ld with it? And do I need any other flags? Ie I'm doing this gcc -flto one.c two.c According to https://gcc.gnu.org/wiki/LinkTimeOptimization#Requirements , Despite the " link time " name, LTO does not need to use any special linker features. The basic mechanism needed is the detection of GIMPLE sections inside object files. This is currently implemented in collect2 . Therefore, LTO will work on any linker already supported by GCC. Furthermore, the GCC

An objcopy equivalent for Mac / iPhone?

耗尽温柔 提交于 2019-11-29 05:30:24
I would like to rename symbols inside object files (.o) with something that would be the Mac equivalent of binutils' objcopy --redefine-syms tool. I found no arm-apple-darwin10-objcopy . I tried the MacPorts' arm-elf-binutils port and also tried to play a bit with otool and segedit without much success. Any ideas please? synthesizerpatel Sounds like a job for Agner Fog's objconv . From the announcement : I have now finished making full support for Mach-O files in the object file converter mentioned in my previous posts. You may use it as a replacement for the missing objcopy utility. Objconv