mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-03 04:12:10 +08:00
a8c4d40b57
Clang's integrated assembler supports multiple section with the same name: .section .text,"ax",@progbits,unique,1 nop .section .text,"ax",@progbits,unique,2 nop "unique,N" assigns the number, N, as the section ID, to a section. The valid values of the section ID are between 0 and 4294967295. It can be used to distinguish different sections with the same section name. This is useful with -fno-unique-section-names -ffunction-sections. -ffunction-sections by default generates .text.foo, .text.bar, etc. Using the same string can save lots of space in .strtab. This patch adds section_id to bfd_section and reuses the linker internal bit in BFD section flags, SEC_LINKER_CREATED, for assmebler internal use to mark valid section_id. It also updates objdump to compare section pointers if 2 sections comes from the same file since 2 different sections can have the same section name. bfd/ PR gas/25380 * bfd-in2.h: Regenerated. * ecoff.c (bfd_debug_section): Add section_id. * section.c (bfd_section): Add section_id. (SEC_ASSEMBLER_SECTION_ID): New. (BFD_FAKE_SECTION): Add section_id. binutils/ PR gas/25380 * objdump.c (sym_ok): Return FALSE if 2 sections are in the same file with different section pointers. gas/ PR gas/25380 * config/obj-elf.c (section_match): Removed. (get_section): Also match SEC_ASSEMBLER_SECTION_ID and section_id. (obj_elf_change_section): Replace info and group_name arguments with match_p. Also update the section ID and flags from match_p. (obj_elf_section): Handle "unique,N". Update call to obj_elf_change_section. * config/obj-elf.h (elf_section_match): New. (obj_elf_change_section): Updated. * config/tc-arm.c (start_unwind_section): Update call to obj_elf_change_section. * config/tc-ia64.c (obj_elf_vms_common): Likewise. * config/tc-microblaze.c (microblaze_s_data): Likewise. (microblaze_s_sdata): Likewise. (microblaze_s_rdata): Likewise. (microblaze_s_bss): Likewise. * config/tc-mips.c (s_change_section): Likewise. * config/tc-msp430.c (msp430_profiler): Likewise. * config/tc-rx.c (parse_rx_section): Likewise. * config/tc-tic6x.c (tic6x_start_unwind_section): Likewise. * doc/as.texi: Document "unique,N" in .section directive. * testsuite/gas/elf/elf.exp: Run "unique,N" tests. * testsuite/gas/elf/section15.d: New file. * testsuite/gas/elf/section15.s: Likewise. * testsuite/gas/elf/section16.s: Likewise. * testsuite/gas/elf/section16a.d: Likewise. * testsuite/gas/elf/section16b.d: Likewise. * testsuite/gas/elf/section17.d: Likewise. * testsuite/gas/elf/section17.l: Likewise. * testsuite/gas/elf/section17.s: Likewise. * testsuite/gas/i386/unique.d: Likewise. * testsuite/gas/i386/unique.s: Likewise. * testsuite/gas/i386/x86-64-unique.d: Likewise. * testsuite/gas/i386/i386.exp: Run unique and x86-64-unique. ld/ PR gas/25380 * testsuite/ld-i386/pr22001-1c.S: Use "unique,N" in .section directives. * testsuite/ld-i386/tls-gd1.S: Likewise. * testsuite/ld-x86-64/pr21481b.S: Likewise.
61 lines
1.1 KiB
ArmAsm
61 lines
1.1 KiB
ArmAsm
.section .rodata.foo,"aMS",@progbits,1,unique,1
|
|
.LC0:
|
|
.string "PASS"
|
|
.text
|
|
.globl check
|
|
.type check, @function
|
|
check:
|
|
subq $8, %rsp
|
|
call *get_func1@GOTPCREL(%rip)
|
|
cmpl $func1, %eax
|
|
jne .L3
|
|
movq func1_p@GOTPCREL(%rip), %rdx
|
|
#ifdef __LP64__
|
|
cmpq %rax, (%rdx)
|
|
#else
|
|
cmpl %eax, (%rdx)
|
|
#endif
|
|
jne .L3
|
|
call *func1@GOTPCREL(%rip)
|
|
cmpl $1, %eax
|
|
jne .L3
|
|
call *call_func1@GOTPCREL(%rip)
|
|
cmpl $1, %eax
|
|
jne .L3
|
|
leaq .LC0(%rip), %rdi
|
|
addq $8, %rsp
|
|
jmp *puts@GOTPCREL(%rip)
|
|
.L3:
|
|
call *abort@GOTPCREL(%rip)
|
|
.size check, .-check
|
|
.globl get_func1
|
|
.type get_func1, @function
|
|
get_func1:
|
|
movq func1@GOTPCREL(%rip), %rax
|
|
ret
|
|
.size get_func1, .-get_func1
|
|
.globl call_func1
|
|
.type call_func1, @function
|
|
call_func1:
|
|
jmp *func1@GOTPCREL(%rip)
|
|
.size call_func1, .-call_func1
|
|
.globl func1_p
|
|
.section .rodata.foo,"a",@progbits,unique,2
|
|
.align 8
|
|
.size func1_p, 8
|
|
.type func1_p, @object
|
|
func1_p:
|
|
.dc.a func1
|
|
.text
|
|
implementation1:
|
|
movl $1, %eax
|
|
ret
|
|
.size implementation1, .-implementation1
|
|
.globl func1
|
|
.type func1, @gnu_indirect_function
|
|
func1:
|
|
leaq implementation1(%rip), %rax
|
|
ret
|
|
.size func1, .-func1
|
|
.section .note.GNU-stack,"",@progbits
|