From 55fe8e70a19187ba960fdca6b48f276cf1cd41f4 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 20 Feb 2010 23:20:44 +0200 Subject: [PATCH] simple ELF loader --- loader/loader.c | 156 +++++++++++++++++++++++++++++++++ loader/loader_arm.s | 17 ++++ loader/loader_ia32.s | 26 ++++++ loader/script_arm.lds | 194 ++++++++++++++++++++++++++++++++++++++++ loader/script_ia32.lds | 195 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 588 insertions(+) create mode 100644 loader/loader.c create mode 100644 loader/loader_arm.s create mode 100644 loader/loader_ia32.s create mode 100644 loader/script_arm.lds create mode 100644 loader/script_ia32.lds diff --git a/loader/loader.c b/loader/loader.c new file mode 100644 index 0000000..6a829ff --- /dev/null +++ b/loader/loader.c @@ -0,0 +1,156 @@ +// vim:shiftwidth=2:expandtab +#include +#include +#include +#include +#include + +#define CHECK_(val, fail_operator, expect, err_msg) \ + if (val fail_operator expect) { \ + fprintf(stderr, err_msg ", exiting (%d)\n", (int)(long)val); \ + return 1; \ + } + +#define CHECK_EQ(val, expect, err_msg) \ + CHECK_(val, !=, expect, err_msg) + +#define CHECK_NE(val, expect, err_msg) \ + CHECK_(val, ==, expect, err_msg) + +#define HDR_CHECK_EQ(field, expect, err_msg) \ + CHECK_(hdr.field, !=, expect, err_msg) + +#define HDR_CHECK_NE(field, expect, err_msg) \ + CHECK_(hdr.field, ==, expect, err_msg) + +#define FAIL_PERROR(msg) { \ + perror(msg); \ + return 1; \ +} + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + +typedef struct { + unsigned long start; + unsigned long end; +} maps_range; + +static int is_range_used(maps_range *maps, int map_cnt, unsigned long start, unsigned long end) +{ + int i; + for (i = 0; i < map_cnt; i++) { + if (maps[i].end <= start) + continue; + if (end <= maps[i].start) + continue; + + return i + 1; + } + + return 0; +} + +extern char **environ; +extern void do_entry(Elf32_Addr entry, void *stack_frame, int stack_frame_size, void *exitf); + +int main(int argc, char *argv[]) +{ + Elf32_Ehdr hdr; + Elf32_Phdr *phdr; + FILE *fi; + maps_range maps[16]; + int map_cnt; + int i, ret; + long stack_frame[5]; + + if (argc != 2) { + fprintf(stderr, "usage: %s \n", argv[0]); + return 1; + } + + fi = fopen("/proc/self/maps", "r"); + CHECK_NE(fi, NULL, "fopen maps"); + + for (i = 0; i < ARRAY_SIZE(maps); i++) { + ret = fscanf(fi, "%lx-%lx %*s %*s %*s %*s %*s\n", &maps[i].start, &maps[i].end); + if (ret == 0) + break; + CHECK_EQ(ret, 2, "maps parse error"); + } + fclose(fi); + map_cnt = i; + CHECK_NE(map_cnt, 0, "no maps"); + CHECK_NE(map_cnt, ARRAY_SIZE(maps), "too many maps"); + + fi = fopen(argv[1], "rb"); + if (fi == NULL) + FAIL_PERROR("fopen"); + + if (fread(&hdr, 1, sizeof(hdr), fi) != sizeof(hdr)) + FAIL_PERROR("too small or"); + + if (memcmp(hdr.e_ident, ELFMAG "\x01\x01", SELFMAG + 2) != 0) { + fprintf(stderr, "not 32bit LE ELF?\n"); + return 1; + } + + HDR_CHECK_EQ(e_type, ET_EXEC, "not executable"); +// HDR_CHECK_EQ(e_machine, EM_ARM, "not ARM"); + HDR_CHECK_EQ(e_phentsize, sizeof(Elf32_Phdr), "bad PH entry size"); + HDR_CHECK_NE(e_phnum, 0, "no PH entries"); + + phdr = malloc(hdr.e_phnum * hdr.e_phentsize); + CHECK_NE(phdr, NULL, "OOM"); + + if (fread(phdr, hdr.e_phentsize, hdr.e_phnum, fi) != hdr.e_phnum) + FAIL_PERROR("too small or"); + + for (i = 0; i < hdr.e_phnum; i++) { + Elf32_Addr end_addr = phdr[i].p_vaddr + phdr[i].p_memsz; + Elf32_Addr align; + void *ptr, *map_ptr; + + if (phdr[i].p_type == PT_NOTE) + continue; + if (phdr[i].p_type != PT_LOAD) { + fprintf(stderr, "skipping section %d\n", phdr[i].p_type); + continue; + } + + ret = is_range_used(maps, map_cnt, phdr[i].p_vaddr, end_addr); + if (ret) { + fprintf(stderr, "segment %d (%08x-%08x) hits %08lx-%08lx in maps\n", + i, phdr[i].p_vaddr, end_addr, maps[ret - 1].start, maps[ret - 1].end); + return 1; + } + + printf("load %d %08x-%08x from %08x\n", phdr[i].p_type, + phdr[i].p_vaddr, end_addr, phdr[i].p_offset); + + align = phdr[i].p_vaddr & 0xfff; + map_ptr = (void *)(phdr[i].p_vaddr - align); + ptr = mmap(map_ptr, phdr[i].p_memsz + align, PROT_READ|PROT_WRITE|PROT_EXEC, + MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (ptr == MAP_FAILED || ptr != map_ptr) + FAIL_PERROR("mmap"); + + if (phdr[i].p_filesz > 0) { + if (fseek(fi, phdr[i].p_offset, SEEK_SET) != 0) + FAIL_PERROR("fseek"); + if (fread((char *)ptr + align, 1, phdr[i].p_filesz, fi) != phdr[i].p_filesz) + FAIL_PERROR("too small or"); + } + } + + stack_frame[0] = 1; // argc + stack_frame[1] = (long)argv[1]; + stack_frame[2] = 0; + stack_frame[3] = (long)environ; + stack_frame[4] = 0; + + printf("entering %08x\n", hdr.e_entry); + do_entry(hdr.e_entry, stack_frame, 5, NULL); + + return 0; +} + diff --git a/loader/loader_arm.s b/loader/loader_arm.s new file mode 100644 index 0000000..eec1c75 --- /dev/null +++ b/loader/loader_arm.s @@ -0,0 +1,17 @@ +.text + +/* void do_entry(Elf32_Addr entry, void *stack_frame, int stack_frame_size, void *exitf); */ + +.globl do_entry +do_entry: + sub sp, sp, r2, lsl #2 + mov r4, sp + mov r5, r0 +0: + ldr r0, [r1], #4 + subs r2, r2, #1 + str r0, [r4], #4 + bgt 0b + + mov r0, r3 + bx r5 diff --git a/loader/loader_ia32.s b/loader/loader_ia32.s new file mode 100644 index 0000000..8284491 --- /dev/null +++ b/loader/loader_ia32.s @@ -0,0 +1,26 @@ +.text + +/* void do_entry(Elf32_Addr entry, void *stack_frame, int stack_frame_size, void *exitf); */ + +.globl do_entry +do_entry: + movl 4(%esp), %ebx + movl 8(%esp), %esi + movl 12(%esp), %eax + movl 16(%esp), %edx + + movl %eax, %ecx + shll $2, %ecx + subl %ecx, %esp + + /* copy stack frame */ + movl %esp, %edi +0: + movl (%esi), %ecx + movl %ecx, (%edi) + addl $4, %esi + addl $4, %edi + subl $1, %eax + jg 0b + + jmp *%ebx diff --git a/loader/script_arm.lds b/loader/script_arm.lds new file mode 100644 index 0000000..fdc6921 --- /dev/null +++ b/loader/script_arm.lds @@ -0,0 +1,194 @@ +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); +SECTIONS +{ + mybase = 0x70000000; /* 0x00008000 */ + /* Read-only sections, merged into text segment: */ + PROVIDE (__executable_start = mybase); + . = mybase + SIZEOF_HEADERS; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + KEEP (*(.text.*personality*)) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN (0x8000) - ((0x8000 - .) & (0x8000 - 1)); . = DATA_SEGMENT_ALIGN (0x8000, 0x1000); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } + /* Thread Local Storage sections */ + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + /* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(32 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { KEEP (*(.preinit_array)) } + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { KEEP (*(.init_array)) } + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { KEEP (*(.fini_array)) } + PROVIDE (__fini_array_end = .); + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin*.o(.ctors)) + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) } + .dynamic : { *(.dynamic) } + . = DATA_SEGMENT_RELRO_END (0, .); + .got : { *(.got.plt) *(.got) } + .data : + { + __data_start = . ; + *(.data .data.* .gnu.linkonce.d.*) + KEEP (*(.gnu.linkonce.d.*personality*)) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); + } + . = ALIGN(32 / 8); + _end = .; + _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; + PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) } +} + + diff --git a/loader/script_ia32.lds b/loader/script_ia32.lds new file mode 100644 index 0000000..4573e5a --- /dev/null +++ b/loader/script_ia32.lds @@ -0,0 +1,195 @@ +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_start) +SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32"); SEARCH_DIR("/usr/lib32"); +SECTIONS +{ + mybase = 0x70000000; /* 0x08048000 */ + /* Read-only sections, merged into text segment: */ + PROVIDE (__executable_start = SEGMENT_START("text-segment", mybase)); + . = SEGMENT_START("text-segment", mybase) + SIZEOF_HEADERS; + .interp : { *(.interp) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + *(.rel.ifunc) + } + .rel.plt : + { + *(.rel.plt) + PROVIDE_HIDDEN (__rel_iplt_start = .); + *(.rel.iplt) + PROVIDE_HIDDEN (__rel_iplt_end = .); + } + .init : + { + KEEP (*(.init)) + } =0x90909090 + .plt : { *(.plt) *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0x90909090 + .fini : + { + KEEP (*(.fini)) + } =0x90909090 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + /* Thread Local Storage sections */ + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .got : { *(.got) *(.igot) } + . = DATA_SEGMENT_RELRO_END (12, .); + .got.plt : { *(.got.plt) *(.igot.plt) } + .data : + { + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + _end = .; PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} + -- 2.39.2