summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2013-02-12 11:08:21 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-04-23 12:00:52 (GMT)
commit1c7472dbeb8e8400a28e603b4647453d877c7770 (patch)
treeab8ddee9d24c6f2c4bd1d19973b20de2f90c535d
parenta5bdceea552ed7fde095b69082f5527dd22d4539 (diff)
downloadpoky-1c7472dbeb8e8400a28e603b4647453d877c7770.tar.gz
relocate_sdk.py: Fix corruption of sdk binaries
There are two cases of corruption that the relocate_sdk.py was not correctly dealing with. 1) SDK Extras should be left alone Extra external binaries included in an SDK that were linked against the host's version of /usr/lib/ld-so.so should not get a relocation applied. In the case that was discovered these were LSB compliant binaries that already worked on many hosts. 2) If the interp section is too small generate an error In the case of the qemu user code, it was using its own .ld file to link the executables which overrides the default in the nativesdk binutils. This generated host executables which had a interp section that was too small to relocate. Now the relocate_sdk.py will print an error and continue on such that the error can be fixed by a developer without having to do the difficult task of debugging why it is crashing or not loading correctly. (From OE-Core rev: 4142f6f9392fdd919488151170fb088d4113e0f2) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/relocate_sdk.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py
index 74bb7a5..45d2c24 100755
--- a/scripts/relocate_sdk.py
+++ b/scripts/relocate_sdk.py
@@ -66,7 +66,7 @@ def parse_elf_header():
66 e_ehsize, e_phentsize, e_phnum, e_shentsize, e_shnum, e_shstrndx =\ 66 e_ehsize, e_phentsize, e_phnum, e_shentsize, e_shnum, e_shstrndx =\
67 hdr_struct.unpack(elf_header[16:hdr_size]) 67 hdr_struct.unpack(elf_header[16:hdr_size])
68 68
69def change_interpreter(): 69def change_interpreter(elf_file_name):
70 if arch == 32: 70 if arch == 32:
71 ph_struct = struct.Struct("<IIIIIIII") 71 ph_struct = struct.Struct("<IIIIIIII")
72 else: 72 else:
@@ -89,7 +89,16 @@ def change_interpreter():
89 if p_type == 3: 89 if p_type == 3:
90 # PT_INTERP section 90 # PT_INTERP section
91 f.seek(p_offset) 91 f.seek(p_offset)
92 # External SDKs with mixed pre-compiled binaries should not get
93 # relocated so look for some variant of /lib
94 fname = f.read(11)
95 if fname.startswith("/lib/") or fname.startswith("/lib64/") or fname.startswith("/lib32/") or fname.startswith("/usr/lib32/") or fname.startswith("/usr/lib32/") or fname.startswith("/usr/lib64/"):
96 break
97 if (len(new_dl_path) >= p_filesz):
98 print "ERROR: could not relocate %s, interp size = %i and %i is needed." % (elf_file_name, p_memsz, len(new_dl_path) + 1)
99 break
92 dl_path = new_dl_path + "\0" * (p_filesz - len(new_dl_path)) 100 dl_path = new_dl_path + "\0" * (p_filesz - len(new_dl_path))
101 f.seek(p_offset)
93 f.write(dl_path) 102 f.write(dl_path)
94 break 103 break
95 104
@@ -199,7 +208,7 @@ for e in executables_list:
199 arch = get_arch() 208 arch = get_arch()
200 if arch: 209 if arch:
201 parse_elf_header() 210 parse_elf_header()
202 change_interpreter() 211 change_interpreter(e)
203 change_dl_sysdirs() 212 change_dl_sysdirs()
204 213
205 """ change permissions back """ 214 """ change permissions back """