public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* The macro STACK_BOUNDARY may overflow
@ 2023-03-24 13:48 Paul Iannetta
  2023-03-25 16:28 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Iannetta @ 2023-03-24 13:48 UTC (permalink / raw)
  To: gcc

Hi,

Currently, the macro STACK_BOUNDARY is defined as

  Macro: STACK_BOUNDARY
     Define this macro to the minimum alignment enforced by hardware for
     the stack pointer on this machine.  The definition is a C
     expression for the desired alignment (measured in bits).  This
     value is used as a default if 'PREFERRED_STACK_BOUNDARY' is not
     defined.  On most machines, this should be the same as
     'PARM_BOUNDARY'.

with no mentions about its type and bounds.  However, at some point, the value
of this macro gets assigned to the field "regno_pointer_align" of "struct
emit_status" which points to an "unsigned char", hence if STACK_BOUNDARY gets
bigger than 255, it will overflow...  Thankfully, the backend which defines the
highest value is microblaze with 128 < 255.

The assignment happens in "emit-rtl.c" through the REGNO_POINTER_ALIGN macro:

in function.h:
  #define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO])
in emit-rtl.cc:
  REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = STACK_BOUNDARY;
  [...]
  REGNO_POINTER_ALIGN (VIRTUAL_OUTGOING_ARGS_REGNUM) = STACK_BOUNDARY;

Would it be possible to, either add an explicit bound to STACK_BOUNDARY in the
manual, and/or use an "unsigned int *" rather than and "unsigned char *" for
the field "regno_pointer_align".

Thanks,
Paul





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

end of thread, other threads:[~2024-01-12 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 13:48 The macro STACK_BOUNDARY may overflow Paul Iannetta
2023-03-25 16:28 ` Jeff Law
2024-01-12 10:15   ` Paul Iannetta

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