ld

Put gcc libs .data in specific section?

牧云@^-^@ 提交于 2019-12-13 12:31:25
问题 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

Prevent GCC LTO from deleting function

﹥>﹥吖頭↗ 提交于 2019-12-13 12:25:59
问题 I work with GCC-ARM-Embedded and FreeRTOS. FreeRTOS has the function vTaskSwitchContext() which is used only in some inline assembler code. The problem is: When I use LTO, GCC does not consider the inline assembler code and thinks the function is not used, thus removes it. The linker then fails because the function call in the inline assembler code cannot be resolved. I would apply __attribute__((used)) but I don't want to touch the FreeRTOS code (it's generated by STM32CubeMX). I tried

How to use nasm to generate a dynamic linked exe on windows?

孤街醉人 提交于 2019-12-13 06:21:02
问题 Basically I know we can use this to create a static linked exe on windows 32 bit: nasm -fwin32 test.s cl.exe test.obj /link libcmt.lib But how to create a dynamic-linked exe from the obj file nasm generated? 来源: https://stackoverflow.com/questions/21010335/how-to-use-nasm-to-generate-a-dynamic-linked-exe-on-windows

Undefined reference to main ld

戏子无情 提交于 2019-12-13 04:29:38
问题 I'm trying to link to files - a c file containing a main function and an asm file that simply jumps to the main. I have mingw installed. My files: //kernel.c void some_function(){ } void main(){ char* video_memory = (char*) 0xb8000; *video_memory = 'X'; some_function(); } ;kernel_entry.asm [bits 32] [extern main] call main jmp $ The commands I call to build: gcc -ffreestanding -c kernel.c -o kernel.o nasm kernel_entry.asm -f elf -o kernel_entry.o ld -o kernel.bin -Ttext 0x1000 kernel_entry.o

examining text segment in a statically linked executable

泪湿孤枕 提交于 2019-12-13 02:39:39
问题 I have a statically linked application binary that links against multiple user libraries and the pthread library. The application only uses a limited set of functions from each of these libraries. From a previous post Size of a library and the executable and from my experiments I realize that the linker only includes functions(in the executable) that are used/needed and not the entire contents of library. I want to find out which functions from each of the respective libraries are linked to

compiler gives error ld terminated with signal 11

会有一股神秘感。 提交于 2019-12-13 02:34:50
问题 I am trying to compile a simple hello program using gcc, but getting the below error. i am using ubuntu. gcc -g -o hello hello.c collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped compilation terminated. strace ld -v execve("/usr/bin/ld", ["ld", "-v"], 0x7ffc43b744c8 /* 57 vars */) = 0 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x2} --- +++ killed by SIGSEGV (core dumped) +++ Segmentation fault (core dumped) I tried reinstalling gcc and

/usr/bin/x86_64-linux-gnu-ld: cannot find?

倾然丶 夕夏残阳落幕 提交于 2019-12-13 02:20:46
问题 I study C language in ubuntu 18.04(gcc 7.3) When the make all command is entered, this error occurrs: /usr/bin/x86_64-linux-gnu-ld: can not find -lkeccak The Makefile is as follows. CC=gcc CFLAGS=-03 -fomit-frame-pointer -msse2avx -mavx2 -march=native -std=c99 all: $(CC) $(CFLAGS) -c Lizard.c main.c randombytes.c sha512.c $(CC) $(CFLAGS) -o Lizard Lizard.o main.o randobytes.o sha512.o -lkeccak run: all ./Lizard new: make clean make all ./Lizard Currently the libkeccak.a file is in the same

collect2: fatal error: ld terminated with signal 11 [Segmentation fault]

限于喜欢 提交于 2019-12-12 19:44:08
问题 I actually can not compile a simple "helloworld" in C. When I type "gcc hello.c" the output is: collect2: fatal error: ld terminated with signal 11 [Segmentation fault] Have someone an idea? I tried to reinstall gcc,g++,make,cmake,binutils. None of this things worked. When I type just "ld" in the terminal the output is: "Segmentation Fault" 回答1: I could solve it with sudo apt purge binutils sudo apt remove make sudo apt autoremove sudo apt install build-essential I don't know why it works

Incorrect NASM indirect addressing assembly on macOS

一笑奈何 提交于 2019-12-12 17:07:52
问题 Assembling the following code on macOS: global start default rel section .text start: lea rdx, [buffer + 0] lea rdx, [buffer + 1] lea rdx, [buffer + 2] lea rdx, [buffer + 3] lea rdx, [buffer + 4] lea rdx, [buffer + 5] lea rdx, [buffer + 6] lea rdx, [buffer + 7] lea rdx, [buffer + 8] section .data buffer: db 0,0,0 using the command nasm -fmacho64 -w+all test.asm -o test.o , yields: (with gobjdump -d test.o ) 0000000000000000 <start>: 0: 48 8d 15 38 00 00 00 lea 0x38(%rip),%rdx # 3f <buffer> 7:

How do I create shared library using ld?

☆樱花仙子☆ 提交于 2019-12-12 13:54:25
问题 I know how to create shared libraries using gcc and ln , but how do I create a shared library using only ld when I have object files (from c++ or c code) as input and how do I swap onto new version of library? 回答1: how do I create a shared library using only ld when I have object files (from c++ or c code) as input You could run gcc -v -shared ... to discover what options gcc passes to ld . You could then pass the same arguments to ld directly, and you should end up with identical result.