summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@microsoft.com>2022-08-04 16:30:59 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-09-03 13:10:37 +0100
commita884e8bdbf9b3c8970eea617f82d3d72ff6e47be (patch)
tree3f90bbc8b3965fa0f777b926faa7d989e5634bf1 /scripts
parente576212d25e7ab24599b8758aeab582df1dd3eee (diff)
downloadpoky-a884e8bdbf9b3c8970eea617f82d3d72ff6e47be.tar.gz
relocate_sdk.py: ensure interpreter size error causes relocation to fail
If there is insufficent space to change the interpreter, we were printing an error here but the overall script did not return an error code, and thus the SDK installation appeared to succeed - but some of the binaries will not be in a working state. Allow the relocation to proceed (so we still get a full list of the failures) but error out at the end so that the installation is halted. (From OE-Core rev: 345193f36d08cfe4899c65e8edf3f79db09c50d2) Signed-off-by: Paul Eggleton <paul.eggleton@microsoft.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit c5a9a448e462d3e5457e8403c5a1a54148ecd224) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/relocate_sdk.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py
index 8c0fdb986a..8079d13750 100755
--- a/scripts/relocate_sdk.py
+++ b/scripts/relocate_sdk.py
@@ -97,11 +97,12 @@ def change_interpreter(elf_file_name):
97 if (len(new_dl_path) >= p_filesz): 97 if (len(new_dl_path) >= p_filesz):
98 print("ERROR: could not relocate %s, interp size = %i and %i is needed." \ 98 print("ERROR: could not relocate %s, interp size = %i and %i is needed." \
99 % (elf_file_name, p_memsz, len(new_dl_path) + 1)) 99 % (elf_file_name, p_memsz, len(new_dl_path) + 1))
100 break 100 return False
101 dl_path = new_dl_path + b("\0") * (p_filesz - len(new_dl_path)) 101 dl_path = new_dl_path + b("\0") * (p_filesz - len(new_dl_path))
102 f.seek(p_offset) 102 f.seek(p_offset)
103 f.write(dl_path) 103 f.write(dl_path)
104 break 104 break
105 return True
105 106
106def change_dl_sysdirs(elf_file_name): 107def change_dl_sysdirs(elf_file_name):
107 if arch == 32: 108 if arch == 32:
@@ -215,6 +216,7 @@ else:
215 216
216executables_list = sys.argv[3:] 217executables_list = sys.argv[3:]
217 218
219errors = False
218for e in executables_list: 220for e in executables_list:
219 perms = os.stat(e)[stat.ST_MODE] 221 perms = os.stat(e)[stat.ST_MODE]
220 if os.access(e, os.W_OK|os.R_OK): 222 if os.access(e, os.W_OK|os.R_OK):
@@ -240,7 +242,8 @@ for e in executables_list:
240 arch = get_arch() 242 arch = get_arch()
241 if arch: 243 if arch:
242 parse_elf_header() 244 parse_elf_header()
243 change_interpreter(e) 245 if not change_interpreter(e):
246 errors = True
244 change_dl_sysdirs(e) 247 change_dl_sysdirs(e)
245 248
246 """ change permissions back """ 249 """ change permissions back """
@@ -253,3 +256,6 @@ for e in executables_list:
253 print("New file size for %s is different. Looks like a relocation error!", e) 256 print("New file size for %s is different. Looks like a relocation error!", e)
254 sys.exit(-1) 257 sys.exit(-1)
255 258
259if errors:
260 print("Relocation of one or more executables failed.")
261 sys.exit(-1)