diff options
Diffstat (limited to 'scripts/relocate_sdk.py')
| -rwxr-xr-x | scripts/relocate_sdk.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py index ceca1f2563..99fca86a12 100755 --- a/scripts/relocate_sdk.py +++ b/scripts/relocate_sdk.py | |||
| @@ -112,7 +112,7 @@ def change_interpreter(elf_file_name): | |||
| 112 | f.write(dl_path) | 112 | f.write(dl_path) |
| 113 | break | 113 | break |
| 114 | 114 | ||
| 115 | def change_dl_sysdirs(): | 115 | def change_dl_sysdirs(elf_file_name): |
| 116 | if arch == 32: | 116 | if arch == 32: |
| 117 | sh_fmt = "<IIIIIIIIII" | 117 | sh_fmt = "<IIIIIIIIII" |
| 118 | else: | 118 | else: |
| @@ -156,6 +156,11 @@ def change_dl_sysdirs(): | |||
| 156 | elif name == b(".ldsocache"): | 156 | elif name == b(".ldsocache"): |
| 157 | ldsocache_path = f.read(sh_size) | 157 | ldsocache_path = f.read(sh_size) |
| 158 | new_ldsocache_path = old_prefix.sub(new_prefix, ldsocache_path) | 158 | new_ldsocache_path = old_prefix.sub(new_prefix, ldsocache_path) |
| 159 | new_ldsocache_path = new_ldsocache_path.rstrip(b("\0")) | ||
| 160 | if (len(new_ldsocache_path) >= sh_size): | ||
| 161 | print("ERROR: could not relocate %s, .ldsocache section size = %i and %i is needed." \ | ||
| 162 | % (elf_file_name, sh_size, len(new_ldsocache_path))) | ||
| 163 | sys.exit(-1) | ||
| 159 | # pad with zeros | 164 | # pad with zeros |
| 160 | new_ldsocache_path += b("\0") * (sh_size - len(new_ldsocache_path)) | 165 | new_ldsocache_path += b("\0") * (sh_size - len(new_ldsocache_path)) |
| 161 | # write it back | 166 | # write it back |
| @@ -167,6 +172,10 @@ def change_dl_sysdirs(): | |||
| 167 | path = f.read(4096) | 172 | path = f.read(4096) |
| 168 | new_path = old_prefix.sub(new_prefix, path) | 173 | new_path = old_prefix.sub(new_prefix, path) |
| 169 | new_path = new_path.rstrip(b("\0")) | 174 | new_path = new_path.rstrip(b("\0")) |
| 175 | if (len(new_path) >= 4096): | ||
| 176 | print("ERROR: could not relocate %s, max path size = 4096 and %i is needed." \ | ||
| 177 | % (elf_file_name, len(new_path))) | ||
| 178 | sys.exit(-1) | ||
| 170 | # pad with zeros | 179 | # pad with zeros |
| 171 | new_path += b("\0") * (4096 - len(new_path)) | 180 | new_path += b("\0") * (4096 - len(new_path)) |
| 172 | #print "Changing %s to %s at %s" % (str(path), str(new_path), str(offset)) | 181 | #print "Changing %s to %s at %s" % (str(path), str(new_path), str(offset)) |
| @@ -241,7 +250,7 @@ for e in executables_list: | |||
| 241 | if arch: | 250 | if arch: |
| 242 | parse_elf_header() | 251 | parse_elf_header() |
| 243 | change_interpreter(e) | 252 | change_interpreter(e) |
| 244 | change_dl_sysdirs() | 253 | change_dl_sysdirs(e) |
| 245 | 254 | ||
| 246 | """ change permissions back """ | 255 | """ change permissions back """ |
| 247 | if perms: | 256 | if perms: |
