[PATCH] gas/config/tc-score7.c: Use symbol_get_frag() instead of direct reference to fix segment fault issue
Chen Gang
gang.chen.5i5j@gmail.com
Sun Jun 8 04:56:00 GMT 2014
If 'symbol' is 'local_symbol' and already local_symbol_converted_p(),
caller has to use symbol_get_frag() instead of direct reference to get
'frag', or may use invalid pointer to cause segment fault.
The related assembly file for score is below, and related statement is
"beq .L10".
.file "conftest.c"
.text
.align 2
.globl foo
.LFB0:
.ent foo
foo:
.frame r2,24,r3, 0 # vars= 4, regs= 4, args= 4, gp= 0
.mask 0x0000300c,-4
sw r13, [r0,-4]+
.LCFI0:
sw r12, [r0,-4]+
.LCFI1:
sw r3, [r0,-4]+
.LCFI2:
sw r2, [r0,-4]+
.LCFI3:
addi r0, -8
.LCFI4:
mv! r2, r0
.LCFI5:
.LEHB0:
jl bar
.LEHE0:
ldiu! r12, 1
.L5:
addri r6, r2, 4
mv! r4, r6
.LEHB1:
jl clean
cmpi.c r12, 1
beq .L10
j .L9
.L6:
mv! r13, r4
ldiu! r12, 0
j .L5
.L9:
mv! r6, r13
mv! r4, r6
jl _Unwind_Resume
.LEHE1:
.L10:
#nop!
addi r2, 8
mv! r0, r2
lw r2, [r0]+, 4
lw r3, [r0]+, 4
lw r12, [r0]+, 4
lw r13, [r0]+, 4
br! r3
.end foo
.LFE0:
.globl __gcc_personality_v0
.section .gcc_except_table,"aw",@progbits
.LLSDA0:
.byte 0xff
.byte 0xff
.byte 0x3
.byte 0x1a
.4byte .LEHB0-.LFB0
.4byte .LEHE0-.LEHB0
.4byte .L6-.LFB0
.byte 0
.4byte .LEHB1-.LFB0
.4byte .LEHE1-.LEHB1
.4byte 0
.byte 0
.text
.size foo, .-foo
.section .eh_frame,"aw",@progbits
.Lframe1:
.4byte .LECIE1-.LSCIE1
.LSCIE1:
.4byte 0
.byte 0x3
.string "zPL"
.byte 0x1
.byte 0x7c
.byte 0x3
.byte 0x6
.byte 0
.4byte __gcc_personality_v0
.byte 0
.byte 0xc
.byte 0
.byte 0
.align 2
.LECIE1:
.LSFDE1:
.4byte .LEFDE1-.LASFDE1
.LASFDE1:
.4byte .LASFDE1-.Lframe1
.4byte .LFB0
.4byte .LFE0-.LFB0
.byte 0x4
.4byte .LLSDA0
.byte 0x4
.4byte .LCFI0-.LFB0
.byte 0xe
.byte 0x4
.byte 0x8d
.byte 0x1
.byte 0x4
.4byte .LCFI1-.LCFI0
.byte 0xe
.byte 0x8
.byte 0x8c
.byte 0x2
.byte 0x4
.4byte .LCFI2-.LCFI1
.byte 0xe
.byte 0xc
.byte 0x83
.byte 0x3
.byte 0x4
.4byte .LCFI3-.LCFI2
.byte 0xe
.byte 0x10
.byte 0x82
.byte 0x4
.byte 0x4
.4byte .LCFI4-.LCFI3
.byte 0xe
.byte 0x18
.byte 0x4
.4byte .LCFI5-.LCFI4
.byte 0xd
.byte 0x2
.align 2
.LEFDE1:
.ident "GCC: (GNU) 4.10.0 20140530 (experimental)"
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
gas/config/tc-score7.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c
index 0a0db2d..8b4206d 100644
--- a/gas/config/tc-score7.c
+++ b/gas/config/tc-score7.c
@@ -5264,7 +5264,7 @@ s7_b32_relax_to_b16 (fragS * fragp)
else
{
if (s->bsym != 0)
- symbol_address = (addressT) s->sy_frag->fr_address;
+ symbol_address = (addressT) symbol_get_frag(s)->fr_address;
}
value = s7_md_chars_to_number (fragp->fr_literal, s7_INSN_SIZE);
--
1.7.11.7
More information about the Binutils
mailing list