public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug translation/64905] New: unsigned short is loaded with 4-byte load (movl)
@ 2015-02-02 18:03 r.ayrapetyan at samsung dot com
  2015-02-02 18:55 ` [Bug target/64905] " hjl.tools at gmail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: r.ayrapetyan at samsung dot com @ 2015-02-02 18:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64905
           Summary: unsigned short is loaded with 4-byte load (movl)
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: translation
          Assignee: unassigned at gcc dot gnu.org
          Reporter: r.ayrapetyan at samsung dot com

Created attachment 34646
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34646&action=edit
Repro case source

Version, target:
  gcc version 5.0.0 20150128 (experimental)
  x86_64-unknown-linux-gnu

Issue:
  In some cases, uint16_t data element is read with 4-byte load (movl
instruction).

Repro case build string:
  gcc -g -Os \
      -ffixed-rax -ffixed-rbx -ffixed-rcx -ffixed-rdx \
      -ffixed-rdi -ffixed-rsi \
      -ffixed-r8 -ffixed-r9 -ffixed-r10 -ffixed-r11 \
      -ffixed-r12 -ffixed-r13 -ffixed-r14 -ffixed-r15 \
      unaligned_read.c -o unaligned_read

Preliminary analysis:
  In the example, ffixed- options are passed to force pointer allocation on the
%rbp register.
  There is another real-world example without ffixed- options, where pointer
was allocated  on the %rbp register and that caused out-of-boundaries memory
access.
  1. The pointer to uint16_t data element was allocated on the %rbp register
     that is marked as aligned to STACK_BOUNDARY.
  2. get_attr_mode called from movhi_internal returns MODE_SI for the
instruction.

This can lead to the following problems:
  1. unaligned memory access (reduced performance);
  2. segmentation fault due to accessing unmapped page (or page mapped with
PROT_NONE)

     // mapped page with array of uint16_t | unmapped page
     function (&array [index_of_last_element_on_the_mapped_page]);
  3. memory access checkers complain about accessing memory out of allocated
array boundaries.


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

end of thread, other threads:[~2015-04-22 13:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 18:03 [Bug translation/64905] New: unsigned short is loaded with 4-byte load (movl) r.ayrapetyan at samsung dot com
2015-02-02 18:55 ` [Bug target/64905] " hjl.tools at gmail dot com
2015-02-02 18:59 ` hjl.tools at gmail dot com
2015-02-02 21:40 ` hjl.tools at gmail dot com
2015-02-04 13:55 ` [Bug rtl-optimization/64905] " ubizjak at gmail dot com
2015-02-04 16:07 ` hjl.tools at gmail dot com
2015-02-04 19:35 ` hjl at gcc dot gnu.org
2015-02-04 19:37 ` hjl.tools at gmail dot com
2015-02-04 19:44 ` dominiq at lps dot ens.fr
2015-02-04 20:03 ` hjl.tools at gmail dot com
2015-02-05 10:04 ` dominiq at lps dot ens.fr
2015-02-05 10:08 ` ubizjak at gmail dot com
2015-02-05 10:37 ` uros at gcc dot gnu.org
2015-04-22 12:02 ` jakub at gcc dot gnu.org
2015-04-22 13:53 ` r.ayrapetyan at samsung dot com

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