This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] s390: Fix build warning with gcc6 in jmpbuf-unwind.h.


On 07/23/2015 10:30 AM, Andreas Schwab wrote:
Stefan Liebler <stli@linux.vnet.ibm.com> writes:

This patch casts _Unwind_GetCFA return to _Unwind_Ptr first

How can a cast fix a truncated pointer value on s390x?

Andreas.

Why is the pointer truncated on s390x?
All three types _Unwind_Word, _Unwind_Ptr and void * have a size of 4bytes on s390 and 8 bytes on s390x.


#include <unwind.h>

void *
convert (_Unwind_Word in)
{
  return (void *) (_Unwind_Ptr) in;
}


Compiling the above function leads to a lr/lgr (with -O0):
s390:
004006b0 <convert>:
  4006b0:       90 bf f0 2c             stm     %r11,%r15,44(%r15)
  4006b4:       a7 fa ff 98             ahi     %r15,-104
  4006b8:       18 bf                   lr      %r11,%r15
  4006ba:       50 20 b0 64             st      %r2,100(%r11)
  4006be:       58 10 b0 64             l       %r1,100(%r11)
  4006c2:       18 21                   lr      %r2,%r1
  4006c4:       58 40 b0 a0             l       %r4,160(%r11)
  4006c8:       98 bf b0 94             lm      %r11,%r15,148(%r11)
  4006cc:       07 f4                   br      %r4

s390x:
0000000080000728 <convert>:
    80000728:   eb bf f0 58 00 24       stmg    %r11,%r15,88(%r15)
    8000072e:   e3 f0 ff 58 ff 71       lay     %r15,-168(%r15)
    80000734:   b9 04 00 bf             lgr     %r11,%r15
    80000738:   e3 20 b0 a0 00 24       stg     %r2,160(%r11)
    8000073e:   e3 10 b0 a0 00 04       lg      %r1,160(%r11)
    80000744:   b9 04 00 21             lgr     %r2,%r1
    80000748:   e3 40 b1 18 00 04       lg      %r4,280(%r11)
    8000074e:   eb bf b1 00 00 04       lmg     %r11,%r15,256(%r11)
    80000754:   07 f4                   br      %r4

or simply return (with -O2):
s390/s390x:
0000000080000780 <convert>:
    80000780:   07 fe                   br      %r14

Bye
Stefan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]