[Bug gas/23837] Segmentation fault in resolve_symbol_value at symbols.c:1165

2018-10-27 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23837

Alan Modra  changed:

   What|Removed |Added

 CC||amodra at gmail dot com

--- Comment #4 from Alan Modra  ---
Patch committed fixes the segfault, which was due to setting a bogus symbol
frag in git commit 29e6f4745ec.  Include "struc-symbol.h" is generally not a
good idea.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/23837] Segmentation fault in resolve_symbol_value at symbols.c:1165

2018-10-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23837

--- Comment #3 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

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

commit b0d99ba9e9c7d7967b53e271e683b7563b710dae
Author: Alan Modra 
Date:   Sun Oct 28 15:57:17 2018 +1030

PR23837, Segmentation fault in resolve_symbol_value

Local symbols don't have a sy_frag field.

PR 23837
* config/tc-hppa.c: Don't include struc-symbol.h.
(pa_build_unwind_subspace): Call get_symbol_frag rather than
referencing sy_frag.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/23837] Segmentation fault in resolve_symbol_value at symbols.c:1165

2018-10-27 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23837

--- Comment #2 from John David Anglin  ---
Doh, I posted the corrected code in comment #1:

asm(".label hppa_save_regs");
asm(".proc");
asm(".callinfo");

The actual code in gbc.c is:
asm(".proc");
asm(".callinfo");
asm(".label hppa_save_regs");

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/23837] Segmentation fault in resolve_symbol_value at symbols.c:1165

2018-10-27 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23837

--- Comment #1 from John David Anglin  ---
The problem occurs in getting the start callinfo symbol used for the
parisc unwind data.  The following hunk of code in gbc.c isn't quite
right:

#if defined(__hppa__) /* Courtesy of Lamont Jones */
/* the calling sequence */
struct regs {
void *callee_saves[16];
};
void hppa_save_regs(struct regs);

/* the code */

asm(".code");
asm(".export hppa_save_regs, entry");
asm(".label hppa_save_regs");
asm(".proc");
asm(".callinfo");
asm(".entry");

asm("stw%r3,0(%arg0)");
asm("stw%r4,4(%arg0)");
asm("stw%r5,8(%arg0)");
asm("stw%r6,12(%arg0)");
asm("stw%r7,16(%arg0)");
asm("stw%r8,20(%arg0)");
asm("stw%r9,24(%arg0)");
asm("stw%r10,28(%arg0)");
asm("stw%r11,32(%arg0)");
asm("stw%r12,36(%arg0)");
asm("stw%r13,40(%arg0)");
asm("stw%r14,44(%arg0)");
asm("stw%r15,48(%arg0)");
asm("stw%r16,52(%arg0)");
asm("stw%r17,56(%arg0)");
asm("bv 0(%rp)");
asm("stw%r18,60(%arg0)");

asm(".exit");
asm(".procend");
asm(".end");
#endif

The line "asm(".label hppa_save_regs");" should be before the .proc line.
As a result, gas finds the label marking the start of text in the object.  It
doesn't seem to have a valid frag.

I think the above code has been the same for many years.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/23837] New: Segmentation fault in resolve_symbol_value at symbols.c:1165

2018-10-27 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=23837

Bug ID: 23837
   Summary: Segmentation fault in resolve_symbol_value at
symbols.c:1165
   Product: binutils
   Version: 2.31
Status: NEW
  Severity: normal
  Priority: P2
 Component: gas
  Assignee: unassigned at sourceware dot org
  Reporter: danglin at gcc dot gnu.org
  Target Milestone: ---
  Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
 Build: hppa-unknown-linux-gnu

Created attachment 11370
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11370&action=edit
.s file

Assembly of gbc.c from gcl-2.6.12 fails with a segmentation fault.  Attached
assembly source.

The fault occurs here:
(gdb) r
Starting program: /home/dave/opt/gnu/bin/as -o gbc.o gbc.s

Program received signal SIGSEGV, Segmentation fault.
0x00034bac in resolve_symbol_value (symp=0x6f668)
at ../../src/gas/symbols.c:1165
1165  final_val += symp->sy_frag->fr_address / OCTETS_PER_BYTE;
(gdb) bt
#0  0x00034bac in resolve_symbol_value (symp=0x6f668)
at ../../src/gas/symbols.c:1165
#1  0x0003b710 in write_object_file () at ../../src/gas/write.c:2266
#2  0x00013104 in main (argc=, argv=)
at ../../src/gas/as.c:1385
(gdb) p *symp
$1 = {sy_flags = {sy_local_symbol = 0, sy_written = 0, sy_resolved = 0,
sy_resolving = 1, sy_used_in_reloc = 0, sy_used = 0, sy_volatile = 0,
sy_forward_ref = 0, sy_mri_common = 0, sy_weakrefr = 0, sy_weakrefd = 0},
  bsym = 0x8c8c8, sy_value = {X_add_symbol = 0x0, X_op_symbol = 0x0,
X_add_number = 0, X_op = O_constant, X_unsigned = 0, X_extrabit = 0,
X_md = 0}, sy_next = 0x6f760, sy_previous = 0x6f620, sy_frag = 0x655f7265,
  sy_obj = {local = 0, size = 0x0, versioned_name = 0x0}}

It appears the value at symp->sy_frag is set in brk:
(gdb) watch *0x6f688
Watchpoint 2: *0x6f688
(gdb) c
Continuing.

Watchpoint 2: *0x6f688

Old value = 
New value = 0
0xf80d7ad0 in brk () from /lib/hppa-linux-gnu/libc.so.6
(gdb) c
Continuing.

Watchpoint 2: *0x6f688

Old value = 0
New value = 1700754021
0xf80d7ad0 in brk () from /lib/hppa-linux-gnu/libc.so.6
(gdb) p/x *0x6f688
$6 = 0x655f7265
(gdb) bt
#0  0xf80d7ad0 in brk () from /lib/hppa-linux-gnu/libc.so.6
#1  0xf80d7c20 in sbrk () from /lib/hppa-linux-gnu/libc.so.6
#2  0xf80718c4 in __default_morecore () from /lib/hppa-linux-gnu/libc.so.6
#3  0xf806d0e0 in ?? () from /lib/hppa-linux-gnu/libc.so.6
#4  0xf806e210 in ?? () from /lib/hppa-linux-gnu/libc.so.6
#5  0xf806f7cc in malloc () from /lib/hppa-linux-gnu/libc.so.6
#6  0xf8594b3c in _objalloc_alloc (o=0x21000 ,
original_len=) at ../../src/libiberty/objalloc.c:159
#7  0xf8523bc0 in bfd_alloc (abfd=, size=)
at ../../src/bfd/opncls.c:950
#8  0xf85241e4 in bfd_zalloc (abfd=, size=716800)
at ../../src/bfd/opncls.c:998
#9  0xf854ab10 in _bfd_elf_make_empty_symbol (abfd=0xaf000)
at ../../src/bfd/elf.c:8691
#10 0x00034548 in symbol_create (name=, segment=0xae590,
valu=4162225112, frag=0x21000 )
at ../../src/gas/symbols.c:147
#11 0x0003463c in symbol_new (name=, segment=,
valu=, frag=) at ../../src/gas/symbols.c:89
#12 0x000360c4 in symbol_find_or_make (name=0xaf000 "")
at ../../src/gas/symbols.c:532
#13 0x0001f4ac in operand (expressionP=0xf8165c80, mode=(unknown: 4162225112))
at ../../src/gas/expr.c:1305
---Type  to continue, or q  to quit---
#14 0x0001f9a4 in expr (rankarg=, resultP=0x1008,
mode=(unknown: 135168)) at ../../src/gas/expr.c:1765
#15 0x00040cb8 in parse_cons_expression_hppa (exp=0xf8165c80)
at ../../src/gas/config/tc-hppa.c:2490
#16 0x0002d530 in cons_worker (nbytes=135168, rva=2672)
at ../../src/gas/read.c:4004
#17 0x0003e338 in pa_cons (nbytes=)
at ../../src/gas/config/tc-hppa.c:8160
#18 0x000303ac in read_a_source_file (name=)
at ../../src/gas/read.c:1148
#19 0x00012ec8 in perform_an_assembly_pass (argv=,
argc=-133469057) at ../../src/gas/as.c:1192
#20 main (argc=, argv=)
at ../../src/gas/as.c:1349
(gdb) disass $pc-32,$pc+32
Dump of assembler code from 0xf80d7ab0 to 0xf80d7af0:
   0xf80d7ab0 :   ldw,mb -80(sp),r7
   0xf80d7ab4 :  stw rp,-14(sp)
   0xf80d7ab8 :  stw,ma r4,40(sp)
   0xf80d7abc :  stw r3,-3c(sp)
   0xf80d7ac0 : stw r19,-20(sp)
   0xf80d7ac4 : copy r19,r4
   0xf80d7ac8 : be,l 100(sr2,r0),sr0,r31
   0xf80d7acc : ldi 2d,r20
=> 0xf80d7ad0 : copy r4,r19
   0xf80d7ad4 : ldi ffd,r20
   0xf80d7ad8 : ldo ffe(ret0),r21
   0xf80d7adc : cmpb,>>= r20,r21,0xf80d7b08 
   0xf80d7ae0 : addil L%1000,r19,r1
   0xf80d7ae4 : ldw 764(r1),r20
   0xf80d7ae8 : stw ret0,0(r20)
   0xf80d7aec : cmpb,<< ret0,r26,0xf80d7b48 
End of assembler dump.
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00034bac in resolve_symbol_value (symp=0x6f668)
at ../../src/gas/symbols.c:1165
1165  final_val += symp->sy_frag->fr_address / OCTETS_PER_BYTE;

-- 
You are receiving this mail because:
Y