Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to the GNU linker "--just-symbols" option for non-GNU linkers?

-R filename

--just-symbols=filename

Read symbol names and their addresses from filename, but do not relocate it or include it in the output. This allows your output file to refer symbolically to absolute locations of memory defined in other programs. You may use this option more than once.

For example, on my Mac, ld -R libsomething.a or even gcc -Wl,-R,libsomething.a doesn't work.

like image 440
Adrian Avatar asked Dec 20 '10 18:12

Adrian


People also ask

What is LD option?

ld normally optimizes for speed over memory usage by caching the symbol tables of input files in memory. This option tells ld to instead optimize for memory usage, by rereading the symbol tables as necessary. This may be required if ld runs out of memory space while linking a large executable.

What is the ld command in linux?

The ld command, also called the linkage editor or binder, combines object files, archives, and import files into one output object file, resolving external references. It produces an executable object file that can be run.

What is ld flags?

ldflags , then, stands for linker flags. It is called this because it passes a flag to the underlying Go toolchain linker, cmd/link , that allows you to change the values of imported packages at build time from the command line.

What does the GNU linker do?

The GNU linker (or GNU ld) is the GNU Project's free software implementation of the Unix command ld. GNU ld runs the linker, which creates an executable file (or a library) from object files created during compilation of a software project.


1 Answers

Since you're talking about "your mac", I assume we are talking about OS X operating systems.

On UNIX-based systems the linker "ld" (with -R option) is used most of the times (see also: ELF). In contrast OS X Systems use the Mach-O binary format and the tool dyld for linking. OS X doesn't provide the same features for libraries as UNIX does. Try otool -L on a binary to see where the libraries are expected. You may also want to try setting DYLD_LIBRARY_PATH (man dyld) for your binaries but keep in mind the security risk (this could be used to inject code like LD_LIBRARY_PATH on UNIX-systems).

like image 186
markusschmitz Avatar answered Sep 28 '22 06:09

markusschmitz