diff options
author | Paul Eggleton <paul.eggleton@microsoft.com> | 2022-08-04 16:30:59 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-23 15:22:52 +0100 |
commit | 84eb7f3b984362f79a23f0a6a89dbe4a3949ffa1 (patch) | |
tree | 57e7af99b1d05179b2a090196670cd040a76aa97 /scripts/relocate_sdk.py | |
parent | 36eb09d20ede32e416fe1bcb4530c0b2c53363bd (diff) | |
download | poky-84eb7f3b984362f79a23f0a6a89dbe4a3949ffa1.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: 3f258378bcaebb9c42c0011c7c424c920ef71d22)
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/relocate_sdk.py')
-rwxr-xr-x | scripts/relocate_sdk.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py index 4ed8bfc0d1..8a728720ba 100755 --- a/scripts/relocate_sdk.py +++ b/scripts/relocate_sdk.py | |||
@@ -104,11 +104,12 @@ def change_interpreter(elf_file_name): | |||
104 | if (len(new_dl_path) >= p_filesz): | 104 | if (len(new_dl_path) >= p_filesz): |
105 | print("ERROR: could not relocate %s, interp size = %i and %i is needed." \ | 105 | print("ERROR: could not relocate %s, interp size = %i and %i is needed." \ |
106 | % (elf_file_name, p_memsz, len(new_dl_path) + 1)) | 106 | % (elf_file_name, p_memsz, len(new_dl_path) + 1)) |
107 | break | 107 | return False |
108 | dl_path = new_dl_path + b("\0") * (p_filesz - len(new_dl_path)) | 108 | dl_path = new_dl_path + b("\0") * (p_filesz - len(new_dl_path)) |
109 | f.seek(p_offset) | 109 | f.seek(p_offset) |
110 | f.write(dl_path) | 110 | f.write(dl_path) |
111 | break | 111 | break |
112 | return True | ||
112 | 113 | ||
113 | def change_dl_sysdirs(elf_file_name): | 114 | def change_dl_sysdirs(elf_file_name): |
114 | if arch == 32: | 115 | if arch == 32: |
@@ -222,6 +223,7 @@ else: | |||
222 | 223 | ||
223 | executables_list = sys.argv[3:] | 224 | executables_list = sys.argv[3:] |
224 | 225 | ||
226 | errors = False | ||
225 | for e in executables_list: | 227 | for e in executables_list: |
226 | perms = os.stat(e)[stat.ST_MODE] | 228 | perms = os.stat(e)[stat.ST_MODE] |
227 | if os.access(e, os.W_OK|os.R_OK): | 229 | if os.access(e, os.W_OK|os.R_OK): |
@@ -247,7 +249,8 @@ for e in executables_list: | |||
247 | arch = get_arch() | 249 | arch = get_arch() |
248 | if arch: | 250 | if arch: |
249 | parse_elf_header() | 251 | parse_elf_header() |
250 | change_interpreter(e) | 252 | if not change_interpreter(e): |
253 | errors = True | ||
251 | change_dl_sysdirs(e) | 254 | change_dl_sysdirs(e) |
252 | 255 | ||
253 | """ change permissions back """ | 256 | """ change permissions back """ |
@@ -260,3 +263,6 @@ for e in executables_list: | |||
260 | print("New file size for %s is different. Looks like a relocation error!", e) | 263 | print("New file size for %s is different. Looks like a relocation error!", e) |
261 | sys.exit(-1) | 264 | sys.exit(-1) |
262 | 265 | ||
266 | if errors: | ||
267 | print("Relocation of one or more executables failed.") | ||
268 | sys.exit(-1) | ||