https://sourceware.org/bugzilla/show_bug.cgi?id=31850

            Bug ID: 31850
           Summary: aarch64: unnecessary GOT entries and relocations for
                    discarded references
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

there should be no GOT entries allocated and no dynamic relocations in the
following binary:

$ cat bug.ld 
OUTPUT_ARCH(aarch64)
SECTIONS
{
  /DISCARD/ : { *(.discard.*) }
  . = 0x10000;
  .text : { *(.text) }
  . = 0x20000;
  .got  : { *(.got) }
}
$ cat bug3.s
.text
sym_local:
        nop

.global sym_global
sym_global:
        nop

.global sym_hidden
.hidden sym_hidden
sym_hidden:
        nop

.section .discard.text,"ax"
discard_text:
        adrp    x0, :got:sym_local
        adrp    x0, :got:sym_global
// See bug 31847
//      adrp    x0, :got:sym_hidden

.section .discard.data,"a"
discard_data:
.xword sym_global
.xword sym_hidden
$ aarch64-none-linux-gnu-ld -shared -T bug.ld bug3.o
$ aarch64-none-linux-gnu-readelf -rW a.out

Relocation section '.rela.dyn' at offset 0x100a8 contains 4 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000000  0000000000000000 R_AARCH64_NONE                            0
0000000000000000  0000000000000000 R_AARCH64_NONE                            0
0000000000000000  0000000000000000 R_AARCH64_NONE                            0
0000000000020010  0000000200000401 R_AARCH64_GLOB_DAT     0000000000010004
sym_global + 0

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to