* [Patch]: aix/xcoff: add a check for invalid .stabx
@ 2011-03-29 12:36 Tristan Gingold
2011-03-30 6:43 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: Tristan Gingold @ 2011-03-29 12:36 UTC (permalink / raw)
To: binutils
Hi,
the following input:
.csect .text[PR]
.stabx "name___XR_R117b___XEXA:V322=&22",-1,133,0
crashes gas because this .stabx in not within .bs/.es
Instead of crashing, this patch emits an error message.
Ok for trunk ?
Tristan.
gas/
2011-03-29 Tristan Gingold <gingold@adacore.com>
* config/tc-ppc.c (ppc_stabx): Add a check.
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 4396e14..1bbaa63 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -3749,6 +3749,9 @@ ppc_stabx (int ignore ATTRIBUTE_UNUSED)
if (S_GET_STORAGE_CLASS (sym) == C_STSYM) {
+ if (ppc_current_block == NULL)
+ as_bad (_(".stabx of storage class stsym must be within .bs/.es"));
+
symbol_get_tc (sym)->within = ppc_current_block;
/* In this case :
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch]: aix/xcoff: add a check for invalid .stabx
2011-03-29 12:36 [Patch]: aix/xcoff: add a check for invalid .stabx Tristan Gingold
@ 2011-03-30 6:43 ` Alan Modra
2011-03-30 8:01 ` Tristan Gingold
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2011-03-30 6:43 UTC (permalink / raw)
To: Tristan Gingold; +Cc: binutils
On Tue, Mar 29, 2011 at 02:36:03PM +0200, Tristan Gingold wrote:
> * config/tc-ppc.c (ppc_stabx): Add a check.
OK.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch]: aix/xcoff: add a check for invalid .stabx
2011-03-30 6:43 ` Alan Modra
@ 2011-03-30 8:01 ` Tristan Gingold
2011-03-30 12:20 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: Tristan Gingold @ 2011-03-30 8:01 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
On Mar 30, 2011, at 8:43 AM, Alan Modra wrote:
> On Tue, Mar 29, 2011 at 02:36:03PM +0200, Tristan Gingold wrote:
>> * config/tc-ppc.c (ppc_stabx): Add a check.
>
> OK.
Thanks, but I now like to change it.
In fact, gcc can generates stsym stabx whose value is a constant and AIX as accept it.
In this case, the value shouldn't be converted into a csect offset.
The following patch implements this behaviour.
Ok for trunk ?
Tristan.
gas/
2011-03-30 Tristan Gingold <gingold@adacore.com>
* config/tc-ppc.c (ppc_frob_symbol): Convert stsym symbols value
to offset only if within is set.
(ppc_stabx): Reformat. For stsym stabs, add a check and set
within only for symbols.
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 4396e14..045a8aa 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -3747,28 +3747,30 @@ ppc_stabx (int ignore ATTRIBUTE_UNUSED)
symbol_get_tc (sym)->output = 1;
- if (S_GET_STORAGE_CLASS (sym) == C_STSYM) {
-
- symbol_get_tc (sym)->within = ppc_current_block;
+ if (S_GET_STORAGE_CLASS (sym) == C_STSYM)
+ {
+ /* In this case :
- /* In this case :
+ .bs name
+ .stabx "z",arrays_,133,0
+ .es
- .bs name
- .stabx "z",arrays_,133,0
- .es
+ .comm arrays_,13768,3
- .comm arrays_,13768,3
+ resolve_symbol_value will copy the exp's "within" into sym's when the
+ offset is 0. Since this seems to be corner case problem,
+ only do the correction for storage class C_STSYM. A better solution
+ would be to have the tc field updated in ppc_symbol_new_hook. */
- resolve_symbol_value will copy the exp's "within" into sym's when the
- offset is 0. Since this seems to be corner case problem,
- only do the correction for storage class C_STSYM. A better solution
- would be to have the tc field updated in ppc_symbol_new_hook. */
+ if (exp.X_op == O_symbol)
+ {
+ if (ppc_current_block == NULL)
+ as_bad (_(".stabx of storage class stsym must be within .bs/.es"));
- if (exp.X_op == O_symbol)
- {
- symbol_get_tc (exp.X_add_symbol)->within = ppc_current_block;
- }
- }
+ symbol_get_tc (sym)->within = ppc_current_block;
+ symbol_get_tc (exp.X_add_symbol)->within = ppc_current_block;
+ }
+ }
if (exp.X_op != O_symbol
|| ! S_IS_EXTERNAL (exp.X_add_symbol)
@@ -5401,13 +5403,22 @@ ppc_frob_symbol (symbolS *sym)
else if (S_GET_STORAGE_CLASS (sym) == C_STSYM)
{
symbolS *block;
- symbolS *csect;
+ valueT base;
- /* The value is the offset from the enclosing csect. */
block = symbol_get_tc (sym)->within;
- csect = symbol_get_tc (block)->within;
- resolve_symbol_value (csect);
- S_SET_VALUE (sym, S_GET_VALUE (sym) - S_GET_VALUE (csect));
+ if (block)
+ {
+ /* The value is the offset from the enclosing csect. */
+ symbolS *csect;
+
+ csect = symbol_get_tc (block)->within;
+ resolve_symbol_value (csect);
+ base = S_GET_VALUE (csect);
+ }
+ else
+ base = 0;
+
+ S_SET_VALUE (sym, S_GET_VALUE (sym) - base);
}
else if (S_GET_STORAGE_CLASS (sym) == C_BINCL
|| S_GET_STORAGE_CLASS (sym) == C_EINCL)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch]: aix/xcoff: add a check for invalid .stabx
2011-03-30 8:01 ` Tristan Gingold
@ 2011-03-30 12:20 ` Alan Modra
2011-03-30 12:45 ` Tristan Gingold
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2011-03-30 12:20 UTC (permalink / raw)
To: Tristan Gingold; +Cc: binutils
On Wed, Mar 30, 2011 at 10:01:24AM +0200, Tristan Gingold wrote:
> Thanks, but I now like to change it.
Um, I wonder should I delay approving this patch in case you have
further changes? :-)
> * config/tc-ppc.c (ppc_frob_symbol): Convert stsym symbols value
> to offset only if within is set.
> (ppc_stabx): Reformat. For stsym stabs, add a check and set
> within only for symbols.
OK.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch]: aix/xcoff: add a check for invalid .stabx
2011-03-30 12:20 ` Alan Modra
@ 2011-03-30 12:45 ` Tristan Gingold
0 siblings, 0 replies; 5+ messages in thread
From: Tristan Gingold @ 2011-03-30 12:45 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
On Mar 30, 2011, at 2:20 PM, Alan Modra wrote:
> On Wed, Mar 30, 2011 at 10:01:24AM +0200, Tristan Gingold wrote:
>> Thanks, but I now like to change it.
>
> Um, I wonder should I delay approving this patch in case you have
> further changes? :-)
That's incremental submission :-) Well, I think this is now complete.
>> * config/tc-ppc.c (ppc_frob_symbol): Convert stsym symbols value
>> to offset only if within is set.
>> (ppc_stabx): Reformat. For stsym stabs, add a check and set
>> within only for symbols.
>
> OK.
Committed. Thanks.
Tristan.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-30 12:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-29 12:36 [Patch]: aix/xcoff: add a check for invalid .stabx Tristan Gingold
2011-03-30 6:43 ` Alan Modra
2011-03-30 8:01 ` Tristan Gingold
2011-03-30 12:20 ` Alan Modra
2011-03-30 12:45 ` Tristan Gingold
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).