public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gas: accept custom ".linefile <n> ."
@ 2022-11-11  7:32 Jan Beulich
  2022-11-14 13:43 ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2022-11-11  7:32 UTC (permalink / raw)
  To: Binutils

While .linefile is generally intended for gas internal use only, its use
in a source file would better not result in an internal error. Give use
of it outside of any macro(-like) construct the meaning of restoring the
original (physical) input file name.

--- a/gas/input-scrub.c
+++ b/gas/input-scrub.c
@@ -469,13 +469,15 @@ new_logical_line_flags (const char *fnam
       /* FIXME: we could check that include nesting is correct.  */
       break;
     case 1 << 3:
-      if (line_number < 0 || fname != NULL || next_saved_file == NULL)
+      if (line_number < 0 || fname != NULL)
 	abort ();
       /* PR gas/16908 workaround: Ignore updates when nested inside a macro
 	 expansion.  */
       if (from_sb_expansion == expanding_nested)
 	return;
-      if (next_saved_file->logical_input_file)
+      if (next_saved_file == NULL)
+	fname = physical_input_file;
+      else if (next_saved_file->logical_input_file)
 	fname = next_saved_file->logical_input_file;
       else
 	fname = next_saved_file->physical_input_file;

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

* Re: [PATCH] gas: accept custom ".linefile <n> ."
  2022-11-11  7:32 [PATCH] gas: accept custom ".linefile <n> ." Jan Beulich
@ 2022-11-14 13:43 ` Nick Clifton
  2022-11-14 15:53   ` Jan Beulich
  2022-11-15  7:59   ` Jan Beulich
  0 siblings, 2 replies; 8+ messages in thread
From: Nick Clifton @ 2022-11-14 13:43 UTC (permalink / raw)
  To: Jan Beulich, Binutils

Hi Jan,

> While .linefile is generally intended for gas internal use only, its use
> in a source file would better not result in an internal error.

Agreed.

> Give use
> of it outside of any macro(-like) construct the meaning of restoring the
> original (physical) input file name.

We should document this behaviour in the as.texi file then, so that it
is "official"...

> --- a/gas/input-scrub.c
> +++ b/gas/input-scrub.c
> @@ -469,13 +469,15 @@ new_logical_line_flags (const char *fnam
>         /* FIXME: we could check that include nesting is correct.  */
>         break;
>       case 1 << 3:
> -      if (line_number < 0 || fname != NULL || next_saved_file == NULL)
> +      if (line_number < 0 || fname != NULL)
>   	abort ();

I still hate having calls to abort() in code.  Much better to have
a helpful error message IMHO.  Not important for this patch though.

Cheers
   Nick



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

* Re: [PATCH] gas: accept custom ".linefile <n> ."
  2022-11-14 13:43 ` Nick Clifton
@ 2022-11-14 15:53   ` Jan Beulich
  2022-11-14 16:02     ` Nick Clifton
  2022-11-15  7:59   ` Jan Beulich
  1 sibling, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2022-11-14 15:53 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Binutils

On 14.11.2022 14:43, Nick Clifton wrote:
>> While .linefile is generally intended for gas internal use only, its use
>> in a source file would better not result in an internal error.
> 
> Agreed.
> 
>> Give use
>> of it outside of any macro(-like) construct the meaning of restoring the
>> original (physical) input file name.
> 
> We should document this behaviour in the as.texi file then, so that it
> is "official"...

Do you really think we should? .linefile as a whole is undocumented. If
people use it, then at their own risk (if we made things "official",
later we couldn't later behavior anymore). The point of the change here
was merely to avoid an internal error that I had noticed. The particular
behavior chosen was simply the one easiest to implement (and at least
halfway sensible) while addressing the issue.

I am, btw, doing further work in this area, which includes zapping
.linefile from listings (where I think it should never have appeared,
but I didn't think of that aspect several months ago). Such zapping
would imo also be unreasonable if the directive became "official".

Jan

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

* Re: [PATCH] gas: accept custom ".linefile <n> ."
  2022-11-14 15:53   ` Jan Beulich
@ 2022-11-14 16:02     ` Nick Clifton
  2022-11-14 16:16       ` Jan Beulich
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Clifton @ 2022-11-14 16:02 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

Hi Jan,

>> We should document this behaviour in the as.texi file then, so that it
>> is "official"...
> 
> Do you really think we should? .linefile as a whole is undocumented. If
> people use it, then at their own risk (if we made things "official",
> later we couldn't later behavior anymore).

Alright - in which case we should document it as being unsupported/not
for use.

I am just trying to avoid the situation where a future binutils user
discovers the directive, tries it out and then complains about it not
working as expected/documented/whatever.

Cheers
   Nick


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

* Re: [PATCH] gas: accept custom ".linefile <n> ."
  2022-11-14 16:02     ` Nick Clifton
@ 2022-11-14 16:16       ` Jan Beulich
  2022-11-15 11:16         ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2022-11-14 16:16 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Binutils

On 14.11.2022 17:02, Nick Clifton wrote:
>>> We should document this behaviour in the as.texi file then, so that it
>>> is "official"...
>>
>> Do you really think we should? .linefile as a whole is undocumented. If
>> people use it, then at their own risk (if we made things "official",
>> later we couldn't later behavior anymore).
> 
> Alright - in which case we should document it as being unsupported/not
> for use.
> 
> I am just trying to avoid the situation where a future binutils user
> discovers the directive, tries it out and then complains about it not
> working as expected/documented/whatever.

Okay, if you could give me a hint where undocumented stuff is to go
in as.texi, I could see about making a patch. Otherwise if you would
make one, it could still educate me in case something else needs
similar treatment going forward.

Jan

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

* Re: [PATCH] gas: accept custom ".linefile <n> ."
  2022-11-14 13:43 ` Nick Clifton
  2022-11-14 15:53   ` Jan Beulich
@ 2022-11-15  7:59   ` Jan Beulich
  2022-11-15 11:23     ` Nick Clifton
  1 sibling, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2022-11-15  7:59 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Binutils

On 14.11.2022 14:43, Nick Clifton wrote:
>> --- a/gas/input-scrub.c
>> +++ b/gas/input-scrub.c
>> @@ -469,13 +469,15 @@ new_logical_line_flags (const char *fnam
>>         /* FIXME: we could check that include nesting is correct.  */
>>         break;
>>       case 1 << 3:
>> -      if (line_number < 0 || fname != NULL || next_saved_file == NULL)
>> +      if (line_number < 0 || fname != NULL)
>>   	abort ();
> 
> I still hate having calls to abort() in code.  Much better to have
> a helpful error message IMHO.  Not important for this patch though.

So do you consider gas_assert() better? I've been using abort() (here
and elsewhere) only because of pre-existing adjacent uses and H.J. at
some point (in x86 code) asking me to use that in favor of gas_assert().
Personally I'd prefer making things like the above assertions. But
perhaps such could also be as_fatal().

Jan

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

* Re: [PATCH] gas: accept custom ".linefile <n> ."
  2022-11-14 16:16       ` Jan Beulich
@ 2022-11-15 11:16         ` Nick Clifton
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2022-11-15 11:16 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

Hi Jan,

>> Alright - in which case we should document it as being unsupported/not
>> for use.

> Okay, if you could give me a hint where undocumented stuff is to go
> in as.texi, I could see about making a patch.

There isn't one. :-)

There is however a node called "AS Sections" which details the assembler
specific sections like .expr.  So there is a (very small) precedence for
this kind of thing.

> Otherwise if you would
> make one, it could still educate me in case something else needs
> similar treatment going forward.

OK, I will look into it.  In the meantime please consider my suggestion
withdrawn.

Cheers
   Nick


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

* Re: [PATCH] gas: accept custom ".linefile <n> ."
  2022-11-15  7:59   ` Jan Beulich
@ 2022-11-15 11:23     ` Nick Clifton
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2022-11-15 11:23 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

Hi Jan,

>>>    	abort ();
>>
>> I still hate having calls to abort() in code.  Much better to have
>> a helpful error message IMHO.  Not important for this patch though.
> 
> So do you consider gas_assert() better? 

Not really.  It still does not tell the user what has gone wrong, nor
does it help them avoid the problem.  Sure they can report it, and having
an abort makes it easier for an investigator to use a debugger to catch
the problem, but in the meantime the user is still left wondering what
went wrong.

The assembler (and other tools) already have a well understood way of
telling the user that something has gone wrong - the exit status code,
along with, hopefully, an error message.  So I think that it is best
to make use of it.

 > But perhaps such could also be as_fatal().

Given a choice, I would definitely prefer as_fatal() over gas_assert()
or abort().  But this is just my preference.  I am not laying down the
law here, and I am not going to reject patches just because they contain
calls to abort.

Cheers
   Nick


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

end of thread, other threads:[~2022-11-15 11:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11  7:32 [PATCH] gas: accept custom ".linefile <n> ." Jan Beulich
2022-11-14 13:43 ` Nick Clifton
2022-11-14 15:53   ` Jan Beulich
2022-11-14 16:02     ` Nick Clifton
2022-11-14 16:16       ` Jan Beulich
2022-11-15 11:16         ` Nick Clifton
2022-11-15  7:59   ` Jan Beulich
2022-11-15 11:23     ` Nick Clifton

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).