bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gas couldn't handle comments leaved by C preprocessor properly


From: Alan Modra
Subject: Re: gas couldn't handle comments leaved by C preprocessor properly
Date: Mon, 4 Oct 2021 10:17:16 +1030

>     In a nutshell, I found that `cpp t.s > t_.s; as t_.s -o t.o` will 
> generate t.o with no symbol:
> 0| $ cpp t.s > t_.s; as t_.s -o t.o
> t_.s: Assembler messages:
> t_.s: Warning: end of file in comment; newline inserted
> 0| $ nm t.o
> 0| $

Can you show the first line of your t_.s?

>     then I begin to research, and perhaps I found where the problem comes 
> from:
>     (/sdcard/input-file.c is binutils-2.37/gas/input-file.c)
> 
> --- /sdcard/input-file.c
> +++ input-file.c
> @@ -191,7 +191,7 @@
>        else if (c == '\n')
>         ungetc ('\n', f_in);
>        else
> -       ungetc ('#', f_in);
> +       ungetc(c, f_in), ungetc ('#', f_in);
>      }
>    else
>      ungetc (c, f_in);
> 
>     This part seems like where simple preprocess the input text. When there 
> is '#' at the beginning of the code with next character isn't 'N' 'A' or 
> '\n', I think this character and '#' should be sent to ungetc() (so that 
> ftell(f_in) return 0), but there is only ungetc('#', f_in). I modified 
> input-file.c, and I successfully solved the problem.

The problem with this patch is that ungetc is only guaranteed to work
for *one* character.  Also, since f_in might be a pipe you can't
rewind.

-- 
Alan Modra
Australia Development Lab, IBM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]