| OLD | NEW |
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 * | 4 * |
| 5 * This is a trivial program to edit an ELF file in place, making | 5 * This is a trivial program to edit an ELF file in place, making |
| 6 * one crucial modification to a program header. It's invoked: | 6 * one crucial modification to a program header. It's invoked: |
| 7 * bootstrap_phdr_hacker FILENAME SEGMENT_NUMBER | 7 * bootstrap_phdr_hacker FILENAME SEGMENT_NUMBER |
| 8 * where SEGMENT_NUMBER is the zero-origin index of the program header | 8 * where SEGMENT_NUMBER is the zero-origin index of the program header |
| 9 * we'll touch. This is a PT_LOAD with p_filesz of zero. We change its | 9 * we'll touch. This is a PT_LOAD with p_filesz of zero. We change its |
| 10 * p_filesz to match its p_memsz value. | 10 * p_filesz to match its p_memsz value. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (elf_flagphdr(elf, ELF_C_SET, ELF_F_DIRTY) == 0) | 57 if (elf_flagphdr(elf, ELF_C_SET, ELF_F_DIRTY) == 0) |
| 58 error(2, 0, "elf_flagphdr: %s", elf_errmsg(-1)); | 58 error(2, 0, "elf_flagphdr: %s", elf_errmsg(-1)); |
| 59 | 59 |
| 60 if (elf_update(elf, ELF_C_WRITE) < 0) | 60 if (elf_update(elf, ELF_C_WRITE) < 0) |
| 61 error(2, 0, "elf_update: %s", elf_errmsg(-1)); | 61 error(2, 0, "elf_update: %s", elf_errmsg(-1)); |
| 62 | 62 |
| 63 close(fd); | 63 close(fd); |
| 64 | 64 |
| 65 return 0; | 65 return 0; |
| 66 } | 66 } |
| OLD | NEW |