KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to create a Shared library (*.so) in ASM and I'm not sure that i do it correct... My code is: .section .data .globl var1 var1: .quad 0x012345 .section .text .globl func1 func1: xor %rax, %rax # mov var1, %rcx # this is commented ret To compile it i run gcc ker.s -g -fPIC -m64 -o ker.o gcc ker.o -shared -fPIC -m64 -o libker.so I can access variable var1 and call func1 with dlopen() and dlsym() from a program in C. The problem is in variable var1. When i try to access it from func1, i.e. uncomment that line, the compiler generates an error: /usr/bin/ld: ker.o: relocation R_X86_64_32S against `var1' can not be used when making a shared object; recompile with -fPIC ker.o: could not read symbols: Bad value collect2: ld returned 1 exit status I don't understand. I've already compiled with -fPIC, so what's wrong?
Tags (comma-separated)
Save Edits
Cancel