public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gas/config/tc-score7.c: Use symbol_get_frag() instead of direct reference to fix segment fault issue
@ 2014-06-08  4:56 Chen Gang
  2014-06-11  2:45 ` Chen Gang
  0 siblings, 1 reply; 4+ messages in thread
From: Chen Gang @ 2014-06-08  4:56 UTC (permalink / raw)
  To: Andreas Schwab, amodra, matthew.fortune, nickc, Pedro Alves; +Cc: binutils

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gas/config/tc-score7.c: Use symbol_get_frag() instead of direct reference to fix segment fault issue
  2014-06-08  4:56 [PATCH] gas/config/tc-score7.c: Use symbol_get_frag() instead of direct reference to fix segment fault issue Chen Gang
@ 2014-06-11  2:45 ` Chen Gang
  2014-06-13 15:10   ` Nicholas Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Chen Gang @ 2014-06-11  2:45 UTC (permalink / raw)
  To: Andreas Schwab, amodra, matthew.fortune, nickc, Pedro Alves; +Cc: binutils

Hello Maintainers:

Is it patch OK? please help check when you have free time, thanks.

Originally, I could not find the related Changelog for 'gas', so I did
not mark change log for it.

BTW: After fix this issue, binutiles and gcc can generated score-elf-*
to compile Linux upstream kernel. And now it can compile Linux upstream
kernel successfully! :-)

Thanks.

On 06/08/2014 12:56 PM, Chen Gang wrote:
> 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);
> 

-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gas/config/tc-score7.c: Use symbol_get_frag() instead of direct reference to fix segment fault issue
  2014-06-11  2:45 ` Chen Gang
@ 2014-06-13 15:10   ` Nicholas Clifton
  2014-06-14  1:51     ` Chen Gang
  0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Clifton @ 2014-06-13 15:10 UTC (permalink / raw)
  To: Chen Gang, Andreas Schwab, amodra, matthew.fortune, Pedro Alves; +Cc: binutils

Hi Chen,

> Is it patch OK? please help check when you have free time, thanks.

Approved and applied.  Note - there were similar errors in tc-score.c so 
I fixed them at the same time.

> Originally, I could not find the related Changelog for 'gas', so I did
> not mark change log for it.

All patches should have a changelog entry, so I created this for yours:

gas/ChangeLog
2014-06-13  Chen Gang  <gang.chen.5i5j@gmail.com>

	* config/tc-score7.c: (s7_b32_relax_to_b16): Use symbol_get_frag() to 
access a symbol's
	frag.
	* config/tc-score.c (s3_relax_branch_inst16): Likewise.
	(s3_relax_cmpbranch_inst32): Likewise.



Also - this is a situation where it would have been appropriate to 
create an official bug report on the bugzilla system.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gas/config/tc-score7.c: Use symbol_get_frag() instead of direct reference to fix segment fault issue
  2014-06-13 15:10   ` Nicholas Clifton
@ 2014-06-14  1:51     ` Chen Gang
  0 siblings, 0 replies; 4+ messages in thread
From: Chen Gang @ 2014-06-14  1:51 UTC (permalink / raw)
  To: Nicholas Clifton, Andreas Schwab, amodra, matthew.fortune, Pedro Alves
  Cc: binutils


Firstly, thank you very much for your work (about the 2 patches), and I
shall continue to try to find and provide new patches to binutils (hope
I can finish 1-3 patches per month).

On 06/13/2014 11:10 PM, Nicholas Clifton wrote:
> Hi Chen,
> 
>> Is it patch OK? please help check when you have free time, thanks.
> 
> Approved and applied.  Note - there were similar errors in tc-score.c so
> I fixed them at the same time.
> 

Thank you for your additional work.

>> Originally, I could not find the related Changelog for 'gas', so I did
>> not mark change log for it.
> 
> All patches should have a changelog entry, so I created this for yours:
> 
> gas/ChangeLog
> 2014-06-13  Chen Gang  <gang.chen.5i5j@gmail.com>
> 
>     * config/tc-score7.c: (s7_b32_relax_to_b16): Use symbol_get_frag()
> to access a symbol's
>     frag.
>     * config/tc-score.c (s3_relax_branch_inst16): Likewise.
>     (s3_relax_cmpbranch_inst32): Likewise.
> 

Thanks again, next, I shall always provide ChangLog for any binutils
patches.

> 
> 
> Also - this is a situation where it would have been appropriate to
> create an official bug report on the bugzilla system.
> 

If it is necessary to let me create the bug report, please let me know
(and then, I shall do). Or please help to try to create it on related
bugzilla system.


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-14  1:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-08  4:56 [PATCH] gas/config/tc-score7.c: Use symbol_get_frag() instead of direct reference to fix segment fault issue Chen Gang
2014-06-11  2:45 ` Chen Gang
2014-06-13 15:10   ` Nicholas Clifton
2014-06-14  1:51     ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).