Bug 19987 - [Aarch64] gold segfaults when handling R_AARCH64_LD64_GOTPAGE_LO15 relocs
Summary: [Aarch64] gold segfaults when handling R_AARCH64_LD64_GOTPAGE_LO15 relocs
Status: ASSIGNED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: ---
Assignee: Han Shen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-24 15:47 UTC by Khem Raj
Modified: 2016-05-09 21:26 UTC (History)
3 users (show)

See Also:
Host: x86_64-linux
Target: aarch64-oe-linux/
Build: x86_64-linux
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khem Raj 2016-04-24 15:47:42 UTC
The test case here

https://uclibc.org/~kraj/gold-aarch64-crash.tar.xz

there is a small script called doit.sh which executes the link steps using both BFD and gold linkers.

demonstrates the problem in gold, while it works ok with BFD linker. The issue seems to be that when its trying to handle R_AARCH64_LD64_GOTPAGE_LO15, there is no entry populsted for it in reloc entry table and hence it gets an assert

/home/kraj01/binutils-gdb/build/gold/ld-new: internal error in global, at ../../gold/aarch64.cc:6218


here is backtrace

#0  get_reloc_property (code=313, this=0xb49530) at ../../gold/aarch64-reloc-property.h:189
#1  global (gsym=0xb99fb0, r_type=313, rela=<synthetic pointer>, output_section=0xb4cdb0, data_shndx=4, object=0xb84d00, target=0xb493b0, layout=0x7fffffff7e50, symtab=0x7fffffff7bd0,
    this=<synthetic pointer>) at ../../gold/aarch64.cc:6217
#2  scan_relocs<64, false, (anonymous namespace)::Target_aarch64<64, false>, (anonymous namespace)::Target_aarch64<64, false>::Scan, gold::Default_classify_reloc<4, 64, false> > (
    plocal_syms=0x7ffff7ff1840 "", local_count=22, needs_special_offset_handling=false, output_section=0xb4cdb0, reloc_count=23, prelocs=0x7ffff7ff1c58 " ", data_shndx=4, object=0xb84d00,
    target=0xb493b0, layout=0x7fffffff7e50, symtab=0x7fffffff7bd0) at ../../gold/target-reloc.h:110
#3  (anonymous namespace)::Target_aarch64<64, false>::scan_relocs (this=0xb493b0, symtab=0x7fffffff7bd0, layout=0x7fffffff7e50, object=0xb84d00, data_shndx=4, sh_type=<optimized out>,
    prelocs=0x7ffff7ff1c40 "\f", reloc_count=23, output_section=0xb4cdb0, needs_special_offset_handling=false, local_symbol_count=22, plocal_symbols=0x7ffff7ff1840 "") at ../../gold/aarch64.cc:6692
#4  0x0000000000681ab7 in gold::Sized_relobj_file<64, false>::do_scan_relocs (this=0xb84d00, symtab=0x7fffffff7bd0, layout=0x7fffffff7e50, rd=0xc2dd50) at ../../gold/reloc.cc:462
#5  0x0000000000680694 in scan_relocs (rd=<optimized out>, layout=<optimized out>, symtab=<optimized out>, this=<optimized out>) at ../../gold/object.h:1156
#6  gold::Scan_relocs::run (this=0xc2e240) at ../../gold/reloc.cc:188
#7  0x00000000006c6f75 in gold::Workqueue::find_and_run_task (this=this@entry=0x7fffffff78c0, thread_number=thread_number@entry=0) at ../../gold/workqueue.cc:319
#8  0x00000000006c729a in gold::Workqueue::process (this=this@entry=0x7fffffff78c0, thread_number=thread_number@entry=0) at ../../gold/workqueue.cc:495
#9  0x0000000000406df6 in main (argc=38, argv=0x7fffffffe178) at ../../gold/main.cc:252
Comment 1 Khem Raj 2016-04-24 15:51:33 UTC
Do we need to have a patch similar to https://sourceware.org/ml/binutils/2015-05/msg00180.html for gold as well ?
Comment 2 Cary Coutant 2016-04-25 17:13:38 UTC
Assigning to Han.

This is a new relocation added to Gnu ld last May.

Even without support for new relocations, gold should not crash or issue an internal error -- we should print a reasonable error message about unsupported relocation.
Comment 3 Sourceware Commits 2016-05-09 21:26:36 UTC
The master branch has been updated by Han Shen <shenhan@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5c28a5038108d75652e1ee9753aa2f1ffe8176db

commit 5c28a5038108d75652e1ee9753aa2f1ffe8176db
Author: Han Shen <shenhan@google.com>
Date:   Fri May 6 15:07:13 2016 -0700

    Fix for PR gold/19987.