public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/58748] New: %n asm output template with symbol references should not be permitted?
@ 2013-10-16 13:05 ktkachov at gcc dot gnu.org
2021-09-13 21:26 ` [Bug middle-end/58748] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2013-10-16 13:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58748
Bug ID: 58748
Summary: %n asm output template with symbol references should
not be permitted?
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: inline-asm
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
consider code:
struct tracepoint {
int dummy;
int state;
};
static struct tracepoint tp;
void test(void)
{
__asm__ ("b %c0" : : "i"(&tp.state));
}
compiling for arm will give the assembly:
test:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
@ 9 "constr.c" 1
b tp+4
@ 0 "" 2
bx lr
.size test, .-test
.bss
.align 2
.type tp, %object
.size tp, 8
tp:
.space 8
Now, if we change the output template from %c to %n:
__asm__ ("b %n0" : : "i"(&tp.state));
we get
test:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
@ 9 "constr.c" 1
b -tp+4
@ 0 "" 2
bx lr
.size test, .-test
.bss
.align 2
.type tp, %object
.size tp, 8
tp:
.space 8
gcc just adds a '-' in front of the tp+4 expression instead of properly
negating it. Now this is reasonably easy to fix in final.c, but I was
wondering: since "-tp + 4" fails to assemble with gas anyway, should we just
forbid the use of %n with non-literal constant expressions?
This situation applies to x86 and aarch64 as well.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/58748] %n asm output template with symbol references should not be permitted?
2013-10-16 13:05 [Bug inline-asm/58748] New: %n asm output template with symbol references should not be permitted? ktkachov at gcc dot gnu.org
@ 2021-09-13 21:26 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-13 21:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58748
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-09-13
Component|inline-asm |middle-end
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, the current code does:
{
putc ('-', asm_out_file);
output_addr_const (asm_out_file, operands[opnum]);
}
I think it should do:
{
fputs ("-(", asm_out_file);
output_addr_const (asm_out_file, operands[opnum]);
putc (')', asm_out_file);
}
Instead.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-13 21:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-16 13:05 [Bug inline-asm/58748] New: %n asm output template with symbol references should not be permitted? ktkachov at gcc dot gnu.org
2021-09-13 21:26 ` [Bug middle-end/58748] " pinskia at gcc dot gnu.org
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).