OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 15, 2024 10:01 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Not understanding R_X86_64_COPY
PostPosted: Mon Mar 09, 2015 1:02 pm 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
I'm trying to implement dynamic library loading in my OS. Currently I handle 4 types of relocations: R_X86_64_64, R_X86_64_JUMP_SLOT, R_X86_64_RELATIVE and R_X86_64_GLOB_DAT. They relocate without problems. I understand I don't need to handle all types of relocations as they don't all appear in dynamic relocation tables... or am I wrong?

The other type of relocation I'm seeing if an executable references an "extern" variable is R_X86_64_COPY. I understand that I have to copy the symbol with the specified name from a library (according to r_offset, st_name and st_size?) but this does not really make sense to me. If the executable modifies the value of this variable the library wouldn't be able to see that change, because it has its own copy.

Or am I misunderstanding something here?


Top
 Profile  
 
 Post subject: Re: Not understanding R_X86_64_COPY
PostPosted: Mon Mar 09, 2015 1:47 pm 
Offline
Member
Member

Joined: Mon Apr 09, 2007 12:10 pm
Posts: 775
Location: London, UK
The library uses the application's copy of the data (via GLOB_DAT relocations in the library). See here for an overview.

Regards,
John.

_________________
Tysos | rpi-boot


Top
 Profile  
 
 Post subject: Re: Not understanding R_X86_64_COPY
PostPosted: Thu Oct 29, 2015 11:21 am 
Offline

Joined: Thu Jan 21, 2010 9:31 pm
Posts: 16
Just implemented R_X86_64_GLOB_DAT and R_X86_64_JUMP_SLOT relocations and they are working great. I ended up doing the same thing where the calculation is really B + S, and not S like you see in the docs. Any idea why the docs state to simply store the st_value as the relocation, but in reality you need to add the lib_base_vaddr + sym->st_value.

It's incredibly misleading.

Thanks,
- Rian


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 49 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group