diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 9 | ||||
-rw-r--r-- | ld/emultempl/elf32.em | 63 | ||||
-rw-r--r-- | ld/scripttempl/elf.sc | 8 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 18 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh.ld | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh1.d | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh1.s | 37 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh1a.s | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh1b.s | 21 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh2.d | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh2.s | 34 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh3.d | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh3.s | 36 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh3a.s | 19 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh4.d | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh5.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/compact-eh6.d | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 12 |
18 files changed, 339 insertions, 19 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 433bdd3..84c268a 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2015-05-28 Catherine Moore <clm@codesourcery.com> + Paul Brook <paul@codesourcery.com> + + ld/ + * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): + Add Compact EH support. + * scripttempl/elf.sc: Handle .eh_frame_entry and .gnu_extab + sections. + 2015-05-17 Chung-Lin Tang <cltang@codesourcery.com> * configure.ac (AC_PROG_GREP): Check for grep program. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 0802d76..cdea5d8 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1045,30 +1045,57 @@ gld${EMULATION_NAME}_after_open (void) return; } - if (link_info.eh_frame_hdr - && !link_info.traditional_format) + if (!link_info.traditional_format) { bfd *abfd, *elfbfd = NULL; bfd_boolean warn_eh_frame = FALSE; asection *s; + int seen_type = 0; for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next) { - if (bfd_count_sections (abfd) == 0) - continue; - if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) - elfbfd = abfd; - if (!warn_eh_frame) + int type = 0; + for (s = abfd->sections; s && type < COMPACT_EH_HDR; s = s->next) { - s = bfd_get_section_by_name (abfd, ".eh_frame"); - while (s != NULL - && (s->size <= 8 - || bfd_is_abs_section (s->output_section))) - s = bfd_get_next_section_by_name (s); - warn_eh_frame = s != NULL; + const char *name = bfd_get_section_name (abfd, s); + + if (bfd_is_abs_section (s->output_section)) + continue; + if (CONST_STRNEQ (name, ".eh_frame_entry")) + type = COMPACT_EH_HDR; + else if (strcmp (name, ".eh_frame") == 0 && s->size > 8) + type = DWARF2_EH_HDR; } - if (elfbfd && warn_eh_frame) - break; + + if (type != 0) + { + if (seen_type == 0) + { + seen_type = type; + } + else if (seen_type != type) + { + einfo (_("%P%F: compact frame descriptions incompatible with" + " DWARF2 .eh_frame from %B\n"), + type == DWARF2_EH_HDR ? abfd : elfbfd); + break; + } + + if (!elfbfd + && (type == COMPACT_EH_HDR || link_info.eh_frame_hdr_type != 0)) + { + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) + elfbfd = abfd; + + warn_eh_frame = TRUE; + } + } + + if (seen_type == COMPACT_EH_HDR) + link_info.eh_frame_hdr_type = COMPACT_EH_HDR; + + if (bfd_count_sections (abfd) == 0) + continue; } if (elfbfd) { @@ -1272,6 +1299,10 @@ fragment <<EOF einfo ("%P: warning: %s, needed by %B, not found (try using -rpath or -rpath-link)\n", l->name, l->by); } + + if (link_info.eh_frame_hdr_type == COMPACT_EH_HDR) + if (bfd_elf_parse_eh_frame_entries (NULL, &link_info) == FALSE) + einfo (_("%P%F: Failed to parse EH frame entries.\n")); } EOF @@ -2222,7 +2253,7 @@ fragment <<EOF break; case OPTION_EH_FRAME_HDR: - link_info.eh_frame_hdr = TRUE; + link_info.eh_frame_hdr_type = DWARF2_EH_HDR; break; case OPTION_GROUP: diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index b4f52eb..c6dfe5d 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -538,10 +538,11 @@ cat <<EOF ${CREATE_SHLIB-${SDATA2}} ${CREATE_SHLIB-${SBSS2}} ${OTHER_READONLY_SECTIONS} - .eh_frame_hdr : { *(.eh_frame_hdr) } - .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .eh_frame_hdr : { *(.eh_frame_hdr) ${RELOCATING+*(.eh_frame_entry .eh_frame_entry.*)} } + .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) } /* These sections are generated by the Sun/Oracle C++ compiler. */ .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges .exception_ranges*) } @@ -554,7 +555,8 @@ cat <<EOF ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} /* Exception handling */ - .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } + .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) } .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 779fc03..1da78f3 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,21 @@ +2015-05-28 Catherine Moore <clm@codesourcery.com> + + ld/testsuite/ + * ld-mips-elf/compact-eh.ld: New linker script. + * ld-mips-elf/compact-eh1.d: New. + * ld-mips-elf/compact-eh1.s: New. + * ld-mips-elf/compact-eh1a.s: New. + * ld-mips-elf/compact-eh1b.s: New. + * ld-mips-elf/compact-eh2.d: New. + * ld-mips-elf/compact-eh2.s: New. + * ld-mips-elf/compact-eh3.d: New. + * ld-mips-elf/compact-eh3.s: New. + * ld-mips-elf/compact-eh3a.s: New. + * ld-mips-elf/compact-eh4.d: New. + * ld-mips-elf/compact-eh5.d: New. + * ld-mips-elf/compact-eh6.d: New. + * ld-mips-elf/mips-elf.exp: Run new tests. + 2015-05-27 H.J. Lu <hongjiu.lu@intel.com> PR binutils/18458 diff --git a/ld/testsuite/ld-mips-elf/compact-eh.ld b/ld/testsuite/ld-mips-elf/compact-eh.ld new file mode 100644 index 0000000..e395fa6 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh.ld @@ -0,0 +1,15 @@ +ENTRY (__start) +SECTIONS +{ + .text : + { + *(.text .text.*) + *(.gnu_extab .gnu_extab.*) + } + .eh_frame_hdr : + { + KEEP (*(.eh_frame_hdr)) + *(.eh_frame_entry .eh_frame_entry.*) + } + .data : {*(.data) } +} diff --git a/ld/testsuite/ld-mips-elf/compact-eh1.d b/ld/testsuite/ld-mips-elf/compact-eh1.d new file mode 100644 index 0000000..b3faafa --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh1.d @@ -0,0 +1,15 @@ +#name: MIPS Compact EH 1 +#source: compact-eh1.s +#source: compact-eh1a.s +#source: compact-eh1b.s +#as: -EB +#readelf: -x .eh_frame_hdr +#ld: -EB -Tcompact-eh.ld -e main +# + +Hex dump of section \'\.eh_frame_hdr\': + + 0x[0-9a-f]+ 021b0000 00000005 ffffff[0-9a-f]+ ffffff[0-9a-f]+.* + 0x[0-9a-f]+ ffffff[0-9a-f]+ ffffff[0-9a-f]+ ffffff[0-9a-f]+ 01555c5c.* + 0x[0-9a-f]+ ffffff[0-9a-f]+ 01555c5c ffffff[0-9a-f]+ 015d5d01.* + diff --git a/ld/testsuite/ld-mips-elf/compact-eh1.s b/ld/testsuite/ld-mips-elf/compact-eh1.s new file mode 100644 index 0000000..941ac8f --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh1.s @@ -0,0 +1,37 @@ + .section .text.startup,"ax",@progbits + .align 2 + .cfi_sections .eh_frame_entry +.LFB3 = . + .cfi_startproc + .cfi_personality_id 0x2 + .cfi_lsda 0x1b,.LLSDA3 + .global main +main: +.LEHB0 = . + jal compact1a + move $4,$2 + +.LEHE0 = . +.L11: + nop + + lw $31,28($sp) + nop + + jal compact1b + move $4,$2 + .cfi_fde_data 0x3,0x42 + .cfi_endproc + .globl __gnu_compact_pr2 + .cfi_inline_lsda 2 +.LLSDA3: + .byte 0x2 + .uleb128 .LLSDACSE3-.LLSDACSB3 +.LLSDACSB3: + # Region 0 -- NoThrow + .uleb128 (.LEHB0-.LFB3)|1 # Length + # Region 1 -- Action Chain + .uleb128 (.LEHE0-.LEHB0) # Length + .sleb128 (.L11-(.LEHE0)) # Landing Pad Offset + .sleb128 (0<<2)|0x1 # Action/Chain Pair +.LLSDACSE3: diff --git a/ld/testsuite/ld-mips-elf/compact-eh1a.s b/ld/testsuite/ld-mips-elf/compact-eh1a.s new file mode 100644 index 0000000..3f5c7ec --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh1a.s @@ -0,0 +1,11 @@ + .cfi_sections .eh_frame_entry + .section .text.compact1a,"ax",@progbits + .globl compact1a + .cfi_startproc +compact1a: + sw $2,16($fp) + lw $2,16($fp) + lw $5,4($3) + addiu $3,$2,1 + .cfi_fde_data 0x5e,0x3,0x59,0xf1 + .cfi_endproc diff --git a/ld/testsuite/ld-mips-elf/compact-eh1b.s b/ld/testsuite/ld-mips-elf/compact-eh1b.s new file mode 100644 index 0000000..e96289a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh1b.s @@ -0,0 +1,21 @@ + .cfi_sections .eh_frame_entry + .section .text.compact1b,"ax",@progbits + .globl compact1b + .cfi_startproc +compact1b: + lw $31,44($sp) + lw $fp,40($sp) + addiu $sp,$sp,48 + j $31 + nop + .cfi_fde_data 0x55 + .cfi_endproc + .globl e22 + .cfi_startproc +__e22: + sw $2,24($fp) + lw $2,24($fp) + xori $2,$2,0x1 + andi $2,$2,0x00ff + .cfi_fde_data 0x55 + .cfi_endproc diff --git a/ld/testsuite/ld-mips-elf/compact-eh2.d b/ld/testsuite/ld-mips-elf/compact-eh2.d new file mode 100644 index 0000000..e9764d5 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh2.d @@ -0,0 +1,11 @@ +#name: MIPS Compact EH 2 +#source: compact-eh2.s +#as: -EB +#readelf: -x .eh_frame_hdr +#ld: -EB -Tcompact-eh.ld -e main +# + +Hex dump of section \'\.eh_frame_hdr\': + + 0x[0-9a-f]+ 021b0000 00000002 ffffff[0-9a-f]+ 00000041.* + 0x[0-9a-f]+ ffffff[0-9a-f]+ 015d5d01.* diff --git a/ld/testsuite/ld-mips-elf/compact-eh2.s b/ld/testsuite/ld-mips-elf/compact-eh2.s new file mode 100644 index 0000000..b899e56 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh2.s @@ -0,0 +1,34 @@ + .section .text.startup,"ax",@progbits + .align 2 + .cfi_sections .eh_frame_entry +.LFB3 = . + .cfi_startproc + .cfi_personality_id 0x2 + .cfi_lsda 0x1b,.LLSDA3 + .global main +main: +.LEHB0 = . + move $4,$2 + +.LEHE0 = . +.L11: + nop + + lw $31,28($sp) + nop + + move $4,$2 + .cfi_endproc + .globl __gnu_compact_pr2 + .cfi_inline_lsda 2 +.LLSDA3: + .byte 0x2 + .uleb128 .LLSDACSE3-.LLSDACSB3 +.LLSDACSB3: + # Region 0 -- NoThrow + .uleb128 (.LEHB0-.LFB3)|1 # Length + # Region 1 -- Action Chain + .uleb128 (.LEHE0-.LEHB0) # Length + .sleb128 (.L11-(.LEHE0)) # Landing Pad Offset + .sleb128 (0<<2)|0x1 # Action/Chain Pair +.LLSDACSE3: diff --git a/ld/testsuite/ld-mips-elf/compact-eh3.d b/ld/testsuite/ld-mips-elf/compact-eh3.d new file mode 100644 index 0000000..7a0ecd6 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh3.d @@ -0,0 +1,13 @@ +#name: MIPS Compact EH 3 +#source: compact-eh3.s +#source: compact-eh3a.s +#as: -EB +#readelf: -x .eh_frame_hdr +#ld: -EB -Tcompact-eh.ld -e main +# + +Hex dump of section \'\.eh_frame_hdr\': + + 0x[0-9a-f]+ 021b0000 00000004 ffffff[0-9a-f]+ ffffff[0-9a-f][0-9a-f].* + 0x[0-9a-f]+ ffffff[0-9a-f]+ 00000041 ffffff[0-9a-f]+ 0000004d.* + 0x[0-9a-f]+ ffffff[0-9a-f]+ 015d5d01.* diff --git a/ld/testsuite/ld-mips-elf/compact-eh3.s b/ld/testsuite/ld-mips-elf/compact-eh3.s new file mode 100644 index 0000000..2bcf5ca --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh3.s @@ -0,0 +1,36 @@ + .section .text.startup,"ax",@progbits + .align 2 + .cfi_sections .eh_frame_entry +.LFB3 = . + .cfi_startproc + .cfi_personality_id 0x2 + .cfi_lsda 0x1b,.LLSDA3 + .global main +main: +.LEHB0 = . + move $4,$2 + +.LEHE0 = . +.L11: + nop + + lw $31,28($sp) + nop + + jal compact3a + move $4,$2 + .cfi_fde_data 0x3,0x42 + .cfi_endproc + .globl __gnu_compact_pr2 + .cfi_inline_lsda 2 +.LLSDA3: + .byte 0x2 + .uleb128 .LLSDACSE3-.LLSDACSB3 +.LLSDACSB3: + # Region 0 -- NoThrow + .uleb128 (.LEHB0-.LFB3)|1 # Length + # Region 1 -- Action Chain + .uleb128 (.LEHE0-.LEHB0) # Length + .sleb128 (.L11-(.LEHE0)) # Landing Pad Offset + .sleb128 (0<<2)|0x1 # Action/Chain Pair +.LLSDACSE3: diff --git a/ld/testsuite/ld-mips-elf/compact-eh3a.s b/ld/testsuite/ld-mips-elf/compact-eh3a.s new file mode 100644 index 0000000..3780cf2 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh3a.s @@ -0,0 +1,19 @@ + .cfi_sections .eh_frame_entry + .section .text.compact3a,"ax",@progbits + .globl compact3a + .cfi_startproc +compact3a: + lw $31,44($sp) + lw $fp,40($sp) + addiu $sp,$sp,48 + j $31 + nop + .cfi_endproc + .globl e22 + .cfi_startproc +__e22: + sw $2,24($fp) + lw $2,24($fp) + xori $3,$4,0x1 + andi $5,$6,0x00ff + .cfi_endproc diff --git a/ld/testsuite/ld-mips-elf/compact-eh4.d b/ld/testsuite/ld-mips-elf/compact-eh4.d new file mode 100644 index 0000000..4608ac8 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh4.d @@ -0,0 +1,13 @@ +#name: MIPS Compact EH 4 +#source: compact-eh1.s +#source: compact-eh1a.s +#source: compact-eh1b.s +#as: -EB +#readelf: -x .eh_frame_hdr +#ld: -EB -e main + +Hex dump of section \'\.eh_frame_hdr\': + + 0x[0-9a-f]+ 021b0000 00000005 ffffff[0-9a-f][0-9a-f] 00000024.* + 0x[0-9a-f]+ ffffff[0-9a-f][0-9a-f] 00000028 ffffff[0-9a-f][0-9a-f] 01555c5c.* + 0x[0-9a-f]+ ffffff[0-9a-f][0-9a-f] 01555c5c ffffff[0-9a-f][0-9a-f] 015d5d01.* diff --git a/ld/testsuite/ld-mips-elf/compact-eh5.d b/ld/testsuite/ld-mips-elf/compact-eh5.d new file mode 100644 index 0000000..7f0141f --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh5.d @@ -0,0 +1,10 @@ +#name: MIPS Compact EH 5 +#source: compact-eh2.s +#as: -EB +#readelf: -x .eh_frame_hdr +#ld: -EB -e main + +Hex dump of section \'\.eh_frame_hdr\': + + 0x[0-9a-f]+ 021b0000 00000002 ffffff[0-9a-f]+ 00000025.* + 0x[0-9a-f]+ ffffff[0-9a-f]+ 015d5d01.* diff --git a/ld/testsuite/ld-mips-elf/compact-eh6.d b/ld/testsuite/ld-mips-elf/compact-eh6.d new file mode 100644 index 0000000..e81285a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/compact-eh6.d @@ -0,0 +1,13 @@ +#name: MIPS Compact EH 6 +#source: compact-eh3.s +#source: compact-eh3a.s +#as: -EB +#readelf: -x .eh_frame_hdr +#ld: -EB -e main +# + +Hex dump of section \'\.eh_frame_hdr\': + + 0x[0-9a-f]+ 021b0000 00000005 ffffff[0-9a-f]+ 00000060.* + 0x[0-9a-f]+ ffffff[0-9a-f]+ 015d5d01 ffffff[0-9a-f]+ 00000029.* + 0x[0-9a-f]+ ffffff[0-9a-f]+ 00000035 ffffff[0-9a-f]+ 015d5d01.* diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 63c55b8..7057e2f 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -432,6 +432,18 @@ if {$linux_gnu} { run_ld_link_tests $eh_frame5_test } +if {$embedded_elf} { + run_dump_test "compact-eh1" + run_dump_test "compact-eh2" + run_dump_test "compact-eh3" +} + +if {$linux_gnu} { + run_dump_test "compact-eh4" + run_dump_test "compact-eh5" + run_dump_test "compact-eh6" +} + run_dump_test "jaloverflow" run_dump_test "jaloverflow-2" run_dump_test "undefweak-overflow" [list [list as $abi_asflags(o32)] \ |