Skip to content

Commit 87f4d86

Browse files
committed
* Fix patching a little-endian binary on a big-endian machine. This
fixes the no-rpath test on powerpc-linux.
1 parent 2b52ef1 commit 87f4d86

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/patchelf.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class ElfFile
157157
template<class I>
158158
I wri(I & t, unsigned long long i)
159159
{
160-
t = rdi(i);
160+
t = rdi((I) i);
161161
return i;
162162
}
163163
};
@@ -389,11 +389,11 @@ void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, Elf_Addr sta
389389
/* Update the offsets in the program headers. */
390390
for (int i = 0; i < rdi(hdr->e_phnum); ++i) {
391391
wri(phdrs[i].p_offset, rdi(phdrs[i].p_offset) + shift);
392-
if (phdrs[i].p_align != 0 &&
393-
(phdrs[i].p_vaddr - phdrs[i].p_offset) % phdrs[i].p_align != 0) {
392+
if (rdi(phdrs[i].p_align) != 0 &&
393+
(rdi(phdrs[i].p_vaddr) - rdi(phdrs[i].p_offset)) % rdi(phdrs[i].p_align) != 0) {
394394
debug("changing alignment of program header %d from %d to %d\n", i,
395-
phdrs[i].p_align, pageSize);
396-
phdrs[i].p_align = pageSize;
395+
rdi(phdrs[i].p_align), pageSize);
396+
wri(phdrs[i].p_align, pageSize);
397397
}
398398
}
399399

0 commit comments

Comments
 (0)