mpw-elfmips.c

来自「基于4个mips核的noc设计」· C语言 代码 · 共 1,443 行 · 第 1/4 页

C
1,443
字号
gldelf32ebmip_place_section (s)     lang_statement_union_type *s;{  lang_output_section_statement_type *os;  if (s->header.type != lang_output_section_statement_enum)    return;  os = &s->output_section_statement;  if (strcmp (os->name, hold_section->name) == 0)    hold_use = os;  if (strcmp (os->name, ".text") == 0)    hold_text = os;  else if (strcmp (os->name, ".rodata") == 0)    hold_rodata = os;  else if (strcmp (os->name, ".data") == 0)    hold_data = os;  else if (strcmp (os->name, ".bss") == 0)    hold_bss = os;  else if (hold_rel == NULL	   && os->bfd_section != NULL	   && strncmp (os->name, ".rel", 4) == 0)    hold_rel = os;}static char *gldelf32ebmip_get_script(isfile)     int *isfile;{			       *isfile = 0;  if (link_info.relocateable == true && config.build_constructors == true)    return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\	      \"elf32-littlemips\")\n\OUTPUT_ARCH(mips)\n\ENTRY(_start)\n\ /* For some reason, the Solaris linker makes bad executables\n\  if gld -r is used and the intermediate file has sections starting\n\  at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld\n\  bug.  But for now assigning the zero vmas works.  */\n\SECTIONS\n\{\n\  /* Read-only sections, merged into text segment: */\n\  .interp   0 : { *(.interp) 	}\n\  .reginfo     0 : { *(.reginfo) }\n\  .dynamic     0 : { *(.dynamic) }\n\  .dynstr      0 : { *(.dynstr)		}\n\  .dynsym      0 : { *(.dynsym)		}\n\  .hash        0 : { *(.hash)		}\n\  .rel.text    0 : { *(.rel.text)		}\n\  .rela.text   0 : { *(.rela.text) 	}\n\  .rel.data    0 : { *(.rel.data)		}\n\  .rela.data   0 : { *(.rela.data) 	}\n\  .rel.rodata  0 : { *(.rel.rodata) 	}\n\  .rela.rodata 0 : { *(.rela.rodata) 	}\n\  .rel.got     0 : { *(.rel.got)		}\n\  .rela.got    0 : { *(.rela.got)		}\n\  .rel.ctors   0 : { *(.rel.ctors)	}\n\  .rela.ctors  0 : { *(.rela.ctors)	}\n\  .rel.dtors   0 : { *(.rel.dtors)	}\n\  .rela.dtors  0 : { *(.rela.dtors)	}\n\  .rel.init    0 : { *(.rel.init)	}\n\  .rela.init   0 : { *(.rela.init)	}\n\  .rel.fini    0 : { *(.rel.fini)	}\n\  .rela.fini   0 : { *(.rela.fini)	}\n\  .rel.bss     0 : { *(.rel.bss)		}\n\  .rela.bss    0 : { *(.rela.bss)		}\n\  .rel.plt     0 : { *(.rel.plt)		}\n\  .rela.plt    0 : { *(.rela.plt)		}\n\  .rodata  0 : { *(.rodata)  }\n\  .rodata1 0 : { *(.rodata1) }\n\  .init        0 : { *(.init)	} =0\n\  .text    0 :\n\  {\n\    *(.text)\n\    *(.stub)\n\    /* .gnu.warning sections are handled specially by elf32.em.  */\n\    *(.gnu.warning)\n\  } =0\n\  .fini    0 : { *(.fini)    } =0\n\  /* Adjust the address for the data segment.  We want to adjust up to\n\     the same address within the page on the next page up.  It would\n\     be more correct to do this:\n\     The current expression does not correctly handle the case of a\n\     text segment ending precisely at the end of a page; it causes the\n\     data segment to skip a page.  The above expression does not have\n\     this problem, but it will currently (2/95) cause BFD to allocate\n\     a single segment, combining both text and data, for this case.\n\     This will prevent the text segment from being shared among\n\     multiple executions of the program; I think that is more\n\     important than losing a page of the virtual address space (note\n\     that no actual memory is lost; the page which is skipped can not\n\     be referenced).  */\n\  .data  0 :\n\  {\n\    *(.data)\n\    CONSTRUCTORS\n\  }\n\  .data1 0 : { *(.data1) }\n\  .ctors       0 : { *(.ctors)   }\n\  .dtors       0 : { *(.dtors)   }\n\  .got         0 :\n\  {\n\    *(.got.plt) *(.got)\n\   }\n\  /* We want the small data sections together, so single-instruction offsets\n\     can access them all, and initialized data all before uninitialized, so\n\     we can shorten the on-disk segment size.  */\n\  .sdata   0 : { *(.sdata) }\n\  .sbss    0 : { *(.sbss) *(.scommon) }\n\  .bss     0 :\n\  {\n\   *(.dynbss)\n\   *(.bss)\n\   *(COMMON)\n\  }\n\  /* These are needed for ELF backends which have not yet been\n\     converted to the new style linker.  */\n\  .stab 0 : { *(.stab) }\n\  .stabstr 0 : { *(.stabstr) }\n\  /* DWARF debug sections.\n\     Symbols in the .debug DWARF section are relative to the beginning of the\n\     section so we begin .debug at 0.  It's not clear yet what needs to happen\n\     for the others.   */\n\  .debug          0 : { *(.debug) }\n\  .debug_srcinfo  0 : { *(.debug_srcinfo) }\n\  .debug_aranges  0 : { *(.debug_aranges) }\n\  .debug_pubnames 0 : { *(.debug_pubnames) }\n\  .debug_sfnames  0 : { *(.debug_sfnames) }\n\  .line           0 : { *(.line) }\n\  /* These must appear regardless of .  */\n\  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\}\n\n";  else if (link_info.relocateable == true)    return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\	      \"elf32-littlemips\")\n\OUTPUT_ARCH(mips)\n\ENTRY(_start)\n\ /* For some reason, the Solaris linker makes bad executables\n\  if gld -r is used and the intermediate file has sections starting\n\  at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld\n\  bug.  But for now assigning the zero vmas works.  */\n\SECTIONS\n\{\n\  /* Read-only sections, merged into text segment: */\n\  .interp   0 : { *(.interp) 	}\n\  .reginfo     0 : { *(.reginfo) }\n\  .dynamic     0 : { *(.dynamic) }\n\  .dynstr      0 : { *(.dynstr)		}\n\  .dynsym      0 : { *(.dynsym)		}\n\  .hash        0 : { *(.hash)		}\n\  .rel.text    0 : { *(.rel.text)		}\n\  .rela.text   0 : { *(.rela.text) 	}\n\  .rel.data    0 : { *(.rel.data)		}\n\  .rela.data   0 : { *(.rela.data) 	}\n\  .rel.rodata  0 : { *(.rel.rodata) 	}\n\  .rela.rodata 0 : { *(.rela.rodata) 	}\n\  .rel.got     0 : { *(.rel.got)		}\n\  .rela.got    0 : { *(.rela.got)		}\n\  .rel.ctors   0 : { *(.rel.ctors)	}\n\  .rela.ctors  0 : { *(.rela.ctors)	}\n\  .rel.dtors   0 : { *(.rel.dtors)	}\n\  .rela.dtors  0 : { *(.rela.dtors)	}\n\  .rel.init    0 : { *(.rel.init)	}\n\  .rela.init   0 : { *(.rela.init)	}\n\  .rel.fini    0 : { *(.rel.fini)	}\n\  .rela.fini   0 : { *(.rela.fini)	}\n\  .rel.bss     0 : { *(.rel.bss)		}\n\  .rela.bss    0 : { *(.rela.bss)		}\n\  .rel.plt     0 : { *(.rel.plt)		}\n\  .rela.plt    0 : { *(.rela.plt)		}\n\  .rodata  0 : { *(.rodata)  }\n\  .rodata1 0 : { *(.rodata1) }\n\  .init        0 : { *(.init)	} =0\n\  .text    0 :\n\  {\n\    *(.text)\n\    *(.stub)\n\    /* .gnu.warning sections are handled specially by elf32.em.  */\n\    *(.gnu.warning)\n\  } =0\n\  .fini    0 : { *(.fini)    } =0\n\  /* Adjust the address for the data segment.  We want to adjust up to\n\     the same address within the page on the next page up.  It would\n\     be more correct to do this:\n\     The current expression does not correctly handle the case of a\n\     text segment ending precisely at the end of a page; it causes the\n\     data segment to skip a page.  The above expression does not have\n\     this problem, but it will currently (2/95) cause BFD to allocate\n\     a single segment, combining both text and data, for this case.\n\     This will prevent the text segment from being shared among\n\     multiple executions of the program; I think that is more\n\     important than losing a page of the virtual address space (note\n\     that no actual memory is lost; the page which is skipped can not\n\     be referenced).  */\n\  .data  0 :\n\  {\n\    *(.data)\n\  }\n\  .data1 0 : { *(.data1) }\n\  .ctors       0 : { *(.ctors)   }\n\  .dtors       0 : { *(.dtors)   }\n\  .got         0 :\n\  {\n\    *(.got.plt) *(.got)\n\   }\n\  /* We want the small data sections together, so single-instruction offsets\n\     can access them all, and initialized data all before uninitialized, so\n\     we can shorten the on-disk segment size.  */\n\  .sdata   0 : { *(.sdata) }\n\  .sbss    0 : { *(.sbss) *(.scommon) }\n\  .bss     0 :\n\  {\n\   *(.dynbss)\n\   *(.bss)\n\   *(COMMON)\n\  }\n\  /* These are needed for ELF backends which have not yet been\n\     converted to the new style linker.  */\n\  .stab 0 : { *(.stab) }\n\  .stabstr 0 : { *(.stabstr) }\n\  /* DWARF debug sections.\n\     Symbols in the .debug DWARF section are relative to the beginning of the\n\     section so we begin .debug at 0.  It's not clear yet what needs to happen\n\     for the others.   */\n\  .debug          0 : { *(.debug) }\n\  .debug_srcinfo  0 : { *(.debug_srcinfo) }\n\  .debug_aranges  0 : { *(.debug_aranges) }\n\  .debug_pubnames 0 : { *(.debug_pubnames) }\n\  .debug_sfnames  0 : { *(.debug_sfnames) }\n\  .line           0 : { *(.line) }\n\  /* These must appear regardless of .  */\n\  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\}\n\n";  else if (!config.text_read_only)    return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\	      \"elf32-littlemips\")\n\OUTPUT_ARCH(mips)\n\ENTRY(_start)\n\ SEARCH_DIR(/usr/local/mips-elf/lib);\n\/* Do we need any of these for elf?\n\   __DYNAMIC = 0;    */\n\SECTIONS\n\{\n\  /* Read-only sections, merged into text segment: */\n\  . = 0x0400000;\n\  .interp     : { *(.interp) 	}\n\  .reginfo       : { *(.reginfo) }\n\  .dynamic       : { *(.dynamic) }\n\  .dynstr        : { *(.dynstr)		}\n\  .dynsym        : { *(.dynsym)		}\n\  .hash          : { *(.hash)		}\n\  .rel.text      : { *(.rel.text)		}\n\  .rela.text     : { *(.rela.text) 	}\n\  .rel.data      : { *(.rel.data)		}\n\  .rela.data     : { *(.rela.data) 	}\n\  .rel.rodata    : { *(.rel.rodata) 	}\n\  .rela.rodata   : { *(.rela.rodata) 	}\n\  .rel.got       : { *(.rel.got)		}\n\  .rela.got      : { *(.rela.got)		}\n\  .rel.ctors     : { *(.rel.ctors)	}\n\  .rela.ctors    : { *(.rela.ctors)	}\n\  .rel.dtors     : { *(.rel.dtors)	}\n\  .rela.dtors    : { *(.rela.dtors)	}\n\  .rel.init      : { *(.rel.init)	}\n\  .rela.init     : { *(.rela.init)	}\n\  .rel.fini      : { *(.rel.fini)	}\n\  .rela.fini     : { *(.rela.fini)	}\n\  .rel.bss       : { *(.rel.bss)		}\n\  .rela.bss      : { *(.rela.bss)		}\n\  .rel.plt       : { *(.rel.plt)		}\n\  .rela.plt      : { *(.rela.plt)		}\n\  .rodata    : { *(.rodata)  }\n\  .rodata1   : { *(.rodata1) }\n\  .init          : { *(.init)	} =0\n\  .text      :\n\  {\n\    _ftext = . ;\n\    *(.text)\n\    *(.stub)\n\    /* .gnu.warning sections are handled specially by elf32.em.  */\n\    *(.gnu.warning)\n\  } =0\n\  _etext = .;\n\  PROVIDE (etext = .);\n\  .fini      : { *(.fini)    } =0\n\  /* Adjust the address for the data segment.  We want to adjust up to\n\     the same address within the page on the next page up.  It would\n\     be more correct to do this:\n\       . = .;\n\     The current expression does not correctly handle the case of a\n\     text segment ending precisely at the end of a page; it causes the\n\     data segment to skip a page.  The above expression does not have\n\     this problem, but it will currently (2/95) cause BFD to allocate\n\     a single segment, combining both text and data, for this case.\n\     This will prevent the text segment from being shared among\n\     multiple executions of the program; I think that is more\n\     important than losing a page of the virtual address space (note\n\     that no actual memory is lost; the page which is skipped can not\n\     be referenced).  */\n\  . += . - 0x0400000;\n\  .data    :\n\  {\n\    _fdata = . ;\n\    *(.data)\n\    CONSTRUCTORS\n\  }\n\  .data1   : { *(.data1) }\n\  .ctors         : { *(.ctors)   }\n\  .dtors         : { *(.dtors)   }\n\  _gp = ALIGN(16) + 0x7ff0;\n\  .got           :\n\  {\n\    *(.got.plt) *(.got)\n\   }\n\  /* We want the small data sections together, so single-instruction offsets\n\     can access them all, and initialized data all before uninitialized, so\n\     we can shorten the on-disk segment size.  */\n\  .sdata     : { *(.sdata) }\n\  .lit8 : { *(.lit8) }\n\  .lit4 : { *(.lit4) }\n\  _edata  =  .;\n\  PROVIDE (edata = .);\n\  __bss_start = .;\n\  _fbss = .;\n\  .sbss      : { *(.sbss) *(.scommon) }\n\  .bss       :\n\  {\n\   *(.dynbss)\n\   *(.bss)\n\   *(COMMON)\n\  }\n\  _end = . ;\n\  PROVIDE (end = .);\n\  /* These are needed for ELF backends which have not yet been\n\     converted to the new style linker.  */\n\  .stab 0 : { *(.stab) }\n\  .stabstr 0 : { *(.stabstr) }\n\  /* DWARF debug sections.\n\     Symbols in the .debug DWARF section are relative to the beginning of the\n\     section so we begin .debug at 0.  It's not clear yet what needs to happen\n\     for the others.   */\n\  .debug          0 : { *(.debug) }\n\  .debug_srcinfo  0 : { *(.debug_srcinfo) }\n\  .debug_aranges  0 : { *(.debug_aranges) }\n\  .debug_pubnames 0 : { *(.debug_pubnames) }\n\  .debug_sfnames  0 : { *(.debug_sfnames) }\n\  .line           0 : { *(.line) }\n\  /* These must appear regardless of  .  */\n\  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\}\n\n";  else if (!config.magic_demand_paged)    return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\	      \"elf32-littlemips\")\n\OUTPUT_ARCH(mips)\n\ENTRY(_start)\n\

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?