ld

Telling ld where to look for directories via an environment variable

痴心易碎 提交于 2021-02-06 10:52:06
问题 I'm grading C and C++ files for a class, and this assignment uses the GSL library. Since I don't have root permission on my computer, my GSL library is installed in my home directory, and thus I need to tell compilers and linkers where to find it. This isn't a problem when I write a program myself, because I just add the appropriate -L and -I flags to gcc. But when I'm compiling student's files, I don't want to edit every one of their makefiles. Instead, I want to put the appropriate

Can LD_PRELOAD be used to load different versions of glibc?

◇◆丶佛笑我妖孽 提交于 2021-02-04 18:51:20
问题 Cast of characters big-old-app is linked to an old version of glibc , say glibc-2.12 . I cannot do anything to change this. cute-new-addon.o is linked to a newer version, glibc-2.23 . This glibc-2.23 is in a nonstandard path (because I don't have sudo powers). The story I want to use cute-new-addon.o inside big-old-app . I would normally write a script for big-old-app to execute, which then calls cute-new-addon.o to perform its tricks. From the command line, it would look like: $ big-old-app

Can LD_PRELOAD be used to load different versions of glibc?

大兔子大兔子 提交于 2021-02-04 18:49:04
问题 Cast of characters big-old-app is linked to an old version of glibc , say glibc-2.12 . I cannot do anything to change this. cute-new-addon.o is linked to a newer version, glibc-2.23 . This glibc-2.23 is in a nonstandard path (because I don't have sudo powers). The story I want to use cute-new-addon.o inside big-old-app . I would normally write a script for big-old-app to execute, which then calls cute-new-addon.o to perform its tricks. From the command line, it would look like: $ big-old-app

How to run manually produce an elf executable using ld?

自作多情 提交于 2021-02-04 08:13:09
问题 I'm trying to get my head around how the linking process works when producing an executable. To do that I'm reading Ian Taylor's blog series about it, but a lot of it is beyond me at the moment - so I'd like to see how it works in practice. At the moment I produce some object files and link them via gcc with: gcc -m32 -o test.o -c test.c gcc -m32 -o main.o -c main.c gcc -m32 -o test main.o test.o How do I replicate the gcc -m32 -o test main.o test.o stage using ld ? I've tried a very naive:

Minimal executable size now 10x larger after linking than 2 years ago, for tiny programs?

半世苍凉 提交于 2021-02-02 02:33:31
问题 For a university course, I like to compare code-sizes of functionally similar programs if written and compiled using gcc/clang versus assembly. In the process of re-evaluating how to further shrink the size of some executables, I couldn't trust my eyes when the very same assembly code I assembled/linked 2 years ago now has grown >10x in size after building it again (which true for multiple programs, not only helloworld): $ make as -32 -o helloworld-asm-2020.o helloworld-asm-2020.s ld -melf

Minimal executable size now 10x larger after linking than 2 years ago, for tiny programs?

旧时模样 提交于 2021-02-02 02:33:08
问题 For a university course, I like to compare code-sizes of functionally similar programs if written and compiled using gcc/clang versus assembly. In the process of re-evaluating how to further shrink the size of some executables, I couldn't trust my eyes when the very same assembly code I assembled/linked 2 years ago now has grown >10x in size after building it again (which true for multiple programs, not only helloworld): $ make as -32 -o helloworld-asm-2020.o helloworld-asm-2020.s ld -melf

How to convert ld -Ttext option to a linker script?

一个人想着一个人 提交于 2021-01-29 03:02:58
问题 I've found this tutorial on creating an operating system, and I'm trying to convert the linking part in the make file into a linker script. Here is the tutorial: https://github.com/ghaiklor/ghaiklor-os-gcc Here is the make file: SOURCES = $(shell find cpu drivers include kernel libc -name '*.c') HEADERS = $(shell find cpu drivers include kernel libc -name '*.h') OBJ = ${SOURCES:.c=.o cpu/interrupt.o} ASM = nasm CC = gcc LD = ld -m elf_i386 CFLAGS = -g -ffreestanding -Wall -Wextra -fno

How to convert ld -Ttext option to a linker script?

大城市里の小女人 提交于 2021-01-29 03:02:15
问题 I've found this tutorial on creating an operating system, and I'm trying to convert the linking part in the make file into a linker script. Here is the tutorial: https://github.com/ghaiklor/ghaiklor-os-gcc Here is the make file: SOURCES = $(shell find cpu drivers include kernel libc -name '*.c') HEADERS = $(shell find cpu drivers include kernel libc -name '*.h') OBJ = ${SOURCES:.c=.o cpu/interrupt.o} ASM = nasm CC = gcc LD = ld -m elf_i386 CFLAGS = -g -ffreestanding -Wall -Wextra -fno

Linker error in AIX - Need explanation about the error “The csect is part of the .text section, and relocation entries”

允我心安 提交于 2021-01-29 02:13:50
问题 I get the following error from the linker 'ld' during linking. ld: 0711-302 ERROR: Object SomeLibrary.a[SomeObject.o], csect <.text> The csect is part of the .text section, and relocation entries from the csect have been written to the .loader section. ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. What does this error mean? (BTW I am using GCC for AIX) 来源: https://stackoverflow.com/questions/55058344/linker-error-in-aix-need-explanation-about-the-error-the

Linker error in AIX - Need explanation about the error “The csect is part of the .text section, and relocation entries”

匆匆过客 提交于 2021-01-29 02:11:25
问题 I get the following error from the linker 'ld' during linking. ld: 0711-302 ERROR: Object SomeLibrary.a[SomeObject.o], csect <.text> The csect is part of the .text section, and relocation entries from the csect have been written to the .loader section. ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. What does this error mean? (BTW I am using GCC for AIX) 来源: https://stackoverflow.com/questions/55058344/linker-error-in-aix-need-explanation-about-the-error-the