From patchwork Fri Jan 25 00:38:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/2] relocate_sdk.py: Fix corruption of sdk binaries Date: Fri, 25 Jan 2013 00:38:45 -0000 From: Jason Wessel X-Patchwork-Id: 43339 Message-Id: <1359074326-12029-1-git-send-email-jason.wessel@windriver.com> To: 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. Signed-off-by: Jason Wessel --- scripts/relocate_sdk.py | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py index 74bb7a5..3e3181f 100755 --- a/scripts/relocate_sdk.py +++ b/scripts/relocate_sdk.py @@ -66,7 +66,7 @@ def parse_elf_header(): e_ehsize, e_phentsize, e_phnum, e_shentsize, e_shnum, e_shstrndx =\ hdr_struct.unpack(elf_header[16:hdr_size]) -def change_interpreter(): +def change_interpreter(elf_file_name): if arch == 32: ph_struct = struct.Struct("= p_memsz): + print "ERROR: could not relocate %s, interp size = %i and %i is needed." % (elf_file_name, p_memsz, len(dl_path)) + break + f.seek(p_offset) + f.write(dl_path ) break def change_dl_sysdirs(): @@ -199,7 +208,7 @@ for e in executables_list: arch = get_arch() if arch: parse_elf_header() - change_interpreter() + change_interpreter(e) change_dl_sysdirs() """ change permissions back """