https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121613

            Bug ID: 121613
           Summary: Support for named address spaces is broken on x32
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

The following testcase:

--cut here--
extern const long __rseq_offset;

struct rseq_area
{
  int a;
  int b;
  int c;
};

int read_rseq (void)
{
  int val = (*(volatile int __seg_fs *)
             (__rseq_offset + __builtin_offsetof (struct rseq_area, c)));
  return val;
}
--cut here--

compiles with -O2 -mx32 to:

read_rseq:
        movl    __rseq_offset(%rip), %eax
        movl    %fs:8(%eax), %eax
        ret

This code will segfault when offset in "%fs:off" is negative, because address
"%fs:off" is calculated as:

EffectiveAddress = FS.base + ZeroExtend32(off)

Reply via email to