OLD | NEW |
---|---|
1 | 1 |
2 # Modifies ld.so's ELF Program Headers to get a version that NaCl's | 2 # Modifies ld.so's ELF Program Headers to get a version that NaCl's |
3 # sel_ldr will run. | 3 # sel_ldr will run. |
4 # | 4 # |
5 # For a discussion, see: | 5 # For a discussion, see: |
6 # http://code.google.com/p/nativeclient/issues/detail?id=156 | 6 # http://code.google.com/p/nativeclient/issues/detail?id=156 |
7 # http://code.google.com/p/nativeclient/issues/detail?id=558 | 7 # http://code.google.com/p/nativeclient/issues/detail?id=558 |
8 | 8 |
9 import struct | 9 import struct |
10 import sys | 10 import sys |
(...skipping 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 def replace(ty, offset, value): | 38 def replace(ty, offset, value): |
39 fh.seek(offset) | 39 fh.seek(offset) |
40 fh.write(struct.pack(ty, value)) | 40 fh.write(struct.pack(ty, value)) |
41 | 41 |
42 # sel_ldr only accepts ELF objects with e_type=ET_EXEC. | 42 # sel_ldr only accepts ELF objects with e_type=ET_EXEC. |
43 check("B", offset_e_type, ET_DYN) | 43 check("B", offset_e_type, ET_DYN) |
44 replace("B", offset_e_type, ET_EXEC) | 44 replace("B", offset_e_type, ET_EXEC) |
45 | 45 |
46 # sel_ldr rejects ELF Program Headers other than PT_LOAD. | 46 # sel_ldr rejects ELF Program Headers other than PT_LOAD. |
47 # Drop PT_DYNAMIC, PT_GNU_STACK and PT_TLS. | 47 # Drop PT_DYNAMIC, PT_GNU_STACK and PT_TLS. |
Mark Seaborn
2013/08/07 16:43:07
We should no longer need to do this. See service_
bradn
2013/08/07 18:30:02
Done.
| |
48 fh.seek(offset_ei_class) | 48 fh.seek(offset_ei_class) |
49 elfclass = fh.read(1) | 49 elfclass = fh.read(1) |
50 if elfclass == elfclass32: | 50 if elfclass == elfclass32: |
51 check("H", offset_e_phnum32, 6) | 51 check("H", offset_e_phnum32, 7) |
52 replace("H", offset_e_phnum32, 3) | 52 replace("H", offset_e_phnum32, 3) |
53 elif elfclass == elfclass64: | 53 elif elfclass == elfclass64: |
54 check("H", offset_e_phnum64, 6) | 54 check("H", offset_e_phnum64, 7) |
55 replace("H", offset_e_phnum64, 3) | 55 replace("H", offset_e_phnum64, 3) |
56 else: | 56 else: |
57 raise AssertionError("Unknown ELF class in file %s." % filename) | 57 raise AssertionError("Unknown ELF class in file %s." % filename) |
58 | 58 |
59 fh.close() | 59 fh.close() |
60 | 60 |
61 | 61 |
62 if __name__ == "__main__": | 62 if __name__ == "__main__": |
63 main(sys.argv[1:]) | 63 main(sys.argv[1:]) |
OLD | NEW |