-
-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix incorrect polarity on dyn_offset; closes #364 #365
Conversation
cc @iv-m |
@@ -1021,7 +1021,7 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress) | |||
if (shdr) { | |||
auto rld_map_addr = findSectionHeader(".rld_map").sh_addr; | |||
auto dyn_offset = ((char*)dyn) - ((char*)dyn_table); | |||
dyn->d_un.d_ptr = rld_map_addr + dyn_offset - (*shdrDynamic).get().sh_addr; | |||
dyn->d_un.d_ptr = rld_map_addr - dyn_offset - (*shdrDynamic).get().sh_addr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the user of this pointer does dyn->d_un.d_ptr + &dyn->d_un.d_ptr
to compute the debug pointer location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the user of this pointer does
dyn->d_un.d_ptr + &dyn->d_un.d_ptr
to compute the debug pointer location?
I'd say, it's dyn + dyn->d_un.d_ptr
. Here is, for example, the relevant part of the glibc's elf loader code (sysdeps/mips/dl-machine.h
):
char *ptr = (char *)(l)->l_info[DT_MIPS (RLD_MAP_REL)]; \
ptr += (l)->l_info[DT_MIPS (RLD_MAP_REL)]->d_un.d_val; \
ping |
Sorry for slow reply, I'm checking this out. |
This patch is correct -- I checked on my MIPS32 LE system that with this patch applied, both before and after applying Apparently I screwed up the signs in #180 and did not notice that: on my mipsel system both So, please merge this pull request. @a-m-joseph, thanks for fixing this. |
No problem. Once this is merged and patchelf makes a release, I would like to upstream all the work I've done on getting nixpkgs to bootstrap on mips64el and mips64el-n32, so it doesn't bitrot. |
This fixes #364 and I have verified that --set-interpreter now works correctly on mips64el-linux-gnuabin32.
However --set-rpath is still broken (produces corrupted binaries); fortunately for that task
chrpath
can be used instead (it works properly).