unix-ar

Extracting archive file in linker script

ぐ巨炮叔叔 提交于 2021-02-19 06:47:06
问题 I am trying to deal with a problem like the following one: Assume that I have a library libxyz.a created from: /* main.c */ int main(void) { int a; } compiled and archived with: gcc -c main.c -o abc.o && ar cr libxyz.a abc.o How do I have to write linker script in order to put abc.o exactly where it is expected to be? I was trying to handle it in such way: /* script.ld */ SEARCH_DIR(.) INPUT(-lxyz) SECTIONS { .text : { xyz:abc(.text) } .data : { xyz:abc(.data) } .bss : { xyz:abc(.bss) } } but