| 1 |
#include <link.h> |
| 2 |
|
| 3 |
// NOTE: This is a minimal test fixture that creates an ELF file with a note |
| 4 |
// segment that has an 8-byte alignment requirement, causing additional padding |
| 5 |
// to be added after the note data. |
| 6 |
|
| 7 |
struct elf_note { |
| 8 |
ElfW(Nhdr) nhdr; // header: 12 bytes |
| 9 |
char name[4]; // name buffer: 2 bytes + 2 bytes padding |
| 10 |
uint8_t data[4]; // data buffer: 1 bytes + 3 bytes padding |
| 11 |
// Due to the 8-byte alignment of the .note segment, |
| 12 |
// an additional 4 bytes of padding is added here: |
| 13 |
uint8_t pad[4]; // pad segment to 8 bytes |
| 14 |
}; |
| 15 |
|
| 16 |
__attribute__((section(".note.custom"), aligned(8))) |
| 17 |
__attribute__((used)) |
| 18 |
const struct elf_note note = { |
| 19 |
.nhdr = { |
| 20 |
.n_namesz = 4, |
| 21 |
.n_descsz = 1, |
| 22 |
.n_type = 0, |
| 23 |
}, |
| 24 |
.name = {'H', 'i', '\0'}, |
| 25 |
.data = {'\x55'}, |
| 26 |
}; |
| 27 |
|
| 28 |
int main() { |
| 29 |
return 0; |
| 30 |
} |