@@ -, +, @@ for ; Thu, 07 Dec 2017 17:19:44 -0800 (PST) d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PBSyJWqX0xWOvHCkBs8Ihevl7ryqoqCycatAt5mY+jk=; b=GDR7/YXBZm00Eo5Pv2IskXG7LWCu+4MU82lOKbKFXHD08Vjm6QVCsjNXQV7Rv/o8se zzr5bqlWYZzTxD0MI/FuDSc4IhW+Xbn40nJb9MRdMrCUbTngdxp93tCLMxjzyD7y1tt0 9pytMOzqBvVJQ+Bi1WNJVOAOxUeUeUDXTIcVZ4pyR+CWNqG0oQOLnALto9OMyoaYB2Ib 7mlIoj/t/somzc02WVjeWwxYIfd8dioIch9rV2AqYezVumtCte+TNVWMqt5Ohv5Mx5I5 krx0O6odZurKyrqr2Rk9YkEK7wSRlwqeVUQ8Im94pgd7XzJwoxmCjbvWLjv8iEIs+75V TarQ== d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PBSyJWqX0xWOvHCkBs8Ihevl7ryqoqCycatAt5mY+jk=; b=A6hINwfPWNtRauIWEfo64BqudyKEGBbaV+e5tKOrFCkHT1sBXQodfJTdKTmgZP3jmr YjrdFZAUv/DaP8Gtbj6XIU4/lYU7FJc3v0VnxYPX0AxS1G73e0qeYktvAE0EEuH9vSe1 jG2/faXoGDtd7MZjBBmlU8oMkJbFLBcAAhpzTiaKmPj7ibKcOUfmHvoDs9H/RVFBsBLV ZsPg1dg9l9emQ/WZKae0ffP2sNtBrwUhD1ELi6gjA/UBBqDRWAlMoJGe5jxE4c1UypDV dCThJbmTZnGqSylZrCwjCgvyMyNLiZoxl+mD9GzAikicQhTJECwCMPjlAhn1WXRU/B7b k+3g== Thu, 07 Dec 2017 17:19:42 -0800 (PST) by smtp.gmail.com with ESMTPSA id v43sm10787378pgn.65.2017.12.07.17.19.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 17:19:41 -0800 (PST) <20171208005012.GM13179@bubble.grove.modra.org> +So it looks like sparc and sparc64 ld needs to be sure to zero section +contents whenever a RELATIVE relocation is emitted, to avoid this +glibc bug. --- a/bfd/elfxx-sparc.c +++ a/bfd/elfxx-sparc.c @@ -3212,10 +3212,6 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, off &= ~1; else { - SPARC_ELF_PUT_WORD (htab, output_bfd, relocation, - htab->elf.sgot->contents + off); - h->got.offset |= 1; - if (h->dynindx == -1 && !h->forced_local && h->root.type != bfd_link_hash_undefweak @@ -3225,6 +3221,10 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, generate R_SPARC_RELATIVE here. */ relative_reloc = TRUE; } + else + SPARC_ELF_PUT_WORD (htab, output_bfd, relocation, + htab->elf.sgot->contents + off); + h->got.offset |= 1; } } else @@ -3245,12 +3245,10 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, else { if (bfd_link_pic (info)) - { - relative_reloc = TRUE; - } - - SPARC_ELF_PUT_WORD (htab, output_bfd, relocation, - htab->elf.sgot->contents + off); + relative_reloc = TRUE; + else + SPARC_ELF_PUT_WORD (htab, output_bfd, relocation, + htab->elf.sgot->contents + off); local_got_offsets[r_symndx] |= 1; } } @@ -3271,8 +3269,14 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, outrel.r_info = SPARC_ELF_R_INFO (htab, NULL, 0, R_SPARC_RELATIVE); outrel.r_addend = relocation; - relocation = 0; sparc_elf_append_rela (output_bfd, s, &outrel); + /* Versions of glibc ld.so at least up to 2.26 wrongly + add the section contents to the value calculated for + a RELATIVE reloc. Zero the contents to work around + this bug. */ + relocation = 0; + SPARC_ELF_PUT_WORD (htab, output_bfd, relocation, + htab->elf.sgot->contents + off); } relocation = htab->elf.sgot->output_offset + off - got_base; --