blob: 7cdf2c1743714467e793fe6869c6b2946df17e6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
From: "Ivan A. Melnikov" <iv@altlinux.org>
Date: Thu, 22 Aug 2019 18:04:57 +0400
Subject: Adjust PT_MIPS_ABIFLAGS segment if present
When loading the executable on MIPS, the dynamic loader looks for MIPS
ABI flags using PT_MIPS_ABIFLAGS header. The flags themselves are stored
in the .MIPS.abiflags section, so the header must be updated when the
section is moved.
Here we also import PT_MIPS_ABIFLAGS definition from glibc commit
0bd956720c457ff054325b48f26ac7c91cb060e8.
Closes: #82
Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
---
src/elf.h | 7 ++++---
src/patchelf.cc | 11 +++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/elf.h b/src/elf.h
index e4e167c..a92289d 100644
--- a/src/elf.h
+++ b/src/elf.h
@@ -1572,9 +1572,10 @@ typedef struct
/* Legal values for p_type field of Elf32_Phdr. */
-#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
-#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
-#define PT_MIPS_OPTIONS 0x70000002
+#define PT_MIPS_REGINFO 0x70000000 /* Register usage information. */
+#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
+#define PT_MIPS_OPTIONS 0x70000002
+#define PT_MIPS_ABIFLAGS 0x70000003 /* FP mode requirement. */
/* Special program header types. */
diff --git a/src/patchelf.cc b/src/patchelf.cc
index d8ea097..fecfc90 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -687,6 +687,17 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
}
}
+ /* If there is .MIPS.abiflags section, then the PT_MIPS_ABIFLAGS
+ segment must be sync'ed with it. */
+ if (sectionName == ".MIPS.abiflags") {
+ for (unsigned int j = 0; j < phdrs.size(); ++j)
+ if (rdi(phdrs[j].p_type) == PT_MIPS_ABIFLAGS) {
+ phdrs[j].p_offset = shdr.sh_offset;
+ phdrs[j].p_vaddr = phdrs[j].p_paddr = shdr.sh_addr;
+ phdrs[j].p_filesz = phdrs[j].p_memsz = shdr.sh_size;
+ }
+ }
+
curOff += roundUp(i.second.size(), sectionAlignment);
}
|