public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug locale/18960] New: s390: _nl_locale_subfreeres uses larl opcode on misaligned symbol
@ 2015-09-13 20:17 koriakin at 0x04 dot net
  2015-09-27 11:39 ` [Bug locale/18960] " koriakin at 0x04 dot net
  0 siblings, 1 reply; 2+ messages in thread
From: koriakin at 0x04 dot net @ 2015-09-13 20:17 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18960

            Bug ID: 18960
           Summary: s390: _nl_locale_subfreeres uses larl opcode on
                    misaligned symbol
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: locale
          Assignee: unassigned at sourceware dot org
          Reporter: koriakin at 0x04 dot net
  Target Milestone: ---

Created attachment 8603
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8603&action=edit
compiled setlocale.c exhibiting this issue

On s390, compiling setlocale.c for static libc with -O2 results in code that
applies larl instruction (basically, load address of symbol using PC-relative
offset) to symbol _nl_current_LC_CTYPE_used.

_nl_current_LC_TYPE_used is defined to be 1 (when corresponding object file is
included) or 0 (when undefined - it's weakly referenced. However, larl
instruction can only load even values - instructions on s390 are 2-byte aligned
and the instruction encodes offset to the target in 2-byte units. This means
it's impossible to properly relocate setlocale.o if the value happens to be set
to 1.

The GNU BFD linker for s390 doesn't bother to check if relocations fit or are
properly aligned. This results in effectively using a symbol value of 0 - ie.
the whole logic of the test is broken.

I ran into this issue while working on s390 port of GNU gold, which did
relocation verification and noticed the problem.

I'm not certain how to resolve this issue. It seems that larl works for
ordinary symbols because gcc aligns everything to 2 bytes anyway. I see the
symbols are already stuffed in a static const pointer array (and not directly
in code) in setlocale.c, but gcc seems to optimize right through it.

Perhaps the symbols could be defined to 2 instead of 1 to work around this
issue? (or a higher value in case some other crazy arch has a similiar issue).

In case your compilation of glibc doesn't exhibit this issue, I attach my
setlocale.o extracted from libc.a. This is FWIW a gentoo system with default
options.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug locale/18960] s390: _nl_locale_subfreeres uses larl opcode on misaligned symbol
  2015-09-13 20:17 [Bug locale/18960] New: s390: _nl_locale_subfreeres uses larl opcode on misaligned symbol koriakin at 0x04 dot net
@ 2015-09-27 11:39 ` koriakin at 0x04 dot net
  0 siblings, 0 replies; 2+ messages in thread
From: koriakin at 0x04 dot net @ 2015-09-27 11:39 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18960

Marcin Kościelnicki <koriakin at 0x04 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |koriakin at 0x04 dot net

--- Comment #1 from Marcin Kościelnicki <koriakin at 0x04 dot net> ---
Seems it should be sufficient to add __attribute__((aligned(1))) to affected
symbols, I'll make a patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From glibc-bugs-return-29940-listarch-glibc-bugs=sources.redhat.com@sourceware.org Sun Sep 27 12:30:29 2015
Return-Path: <glibc-bugs-return-29940-listarch-glibc-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-glibc-bugs@sources.redhat.com
Received: (qmail 117607 invoked by alias); 27 Sep 2015 12:30:29 -0000
Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <glibc-bugs.sourceware.org>
List-Subscribe: <mailto:glibc-bugs-subscribe@sourceware.org>
List-Post: <mailto:glibc-bugs@sourceware.org>
List-Help: <mailto:glibc-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: glibc-bugs-owner@sourceware.org
Delivered-To: mailing list glibc-bugs@sourceware.org
Received: (qmail 117553 invoked by uid 48); 27 Sep 2015 12:30:25 -0000
From: "koriakin at 0x04 dot net" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug locale/18960] s390: _nl_locale_subfreeres uses larl opcode on misaligned symbol
Date: Sun, 27 Sep 2015 12:30:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: glibc
X-Bugzilla-Component: locale
X-Bugzilla-Version: 2.21
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: koriakin at 0x04 dot net
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: koriakin at 0x04 dot net
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags: security-
X-Bugzilla-Changed-Fields: cc attachments.created
Message-ID: <bug-18960-131-7AuvIGtk5z@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18960-131@http.sourceware.org/bugzilla/>
References: <bug-18960-131@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-09/txt/msg00339.txt.bz2
Content-length: 709

https://sourceware.org/bugzilla/show_bug.cgi?id=18960

Marcin Kościelnicki <koriakin at 0x04 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |koriakin at 0x04 dot net

--- Comment #2 from Marcin Kościelnicki <koriakin at 0x04 dot net> ---
Created attachment 8637
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8637&action=edit
Fixes the problem by adding __attribute__((__aligned__(1)))

I think this should fix the problem. Could someone look into it?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From glibc-bugs-return-29941-listarch-glibc-bugs=sources.redhat.com@sourceware.org Sun Sep 27 13:16:56 2015
Return-Path: <glibc-bugs-return-29941-listarch-glibc-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-glibc-bugs@sources.redhat.com
Received: (qmail 78267 invoked by alias); 27 Sep 2015 13:16:55 -0000
Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <glibc-bugs.sourceware.org>
List-Subscribe: <mailto:glibc-bugs-subscribe@sourceware.org>
List-Post: <mailto:glibc-bugs@sourceware.org>
List-Help: <mailto:glibc-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: glibc-bugs-owner@sourceware.org
Delivered-To: mailing list glibc-bugs@sourceware.org
Received: (qmail 78251 invoked by uid 48); 27 Sep 2015 13:16:51 -0000
From: "schwab@linux-m68k.org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug locale/18960] s390: _nl_locale_subfreeres uses larl opcode on misaligned symbol
Date: Sun, 27 Sep 2015 13:16:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: glibc
X-Bugzilla-Component: locale
X-Bugzilla-Version: 2.21
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: schwab@linux-m68k.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: koriakin at 0x04 dot net
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags: security-
X-Bugzilla-Changed-Fields:
Message-ID: <bug-18960-131-YEb0kOv0ia@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18960-131@http.sourceware.org/bugzilla/>
References: <bug-18960-131@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-09/txt/msg00340.txt.bz2
Content-length: 322

https://sourceware.org/bugzilla/show_bug.cgi?id\x18960

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
Patches should be sent to the libc-alpha list.  See
<http://sourceware.org/glibc/wiki/Contribution%20checklist> for details.

--
You are receiving this mail because:
You are on the CC list for the bug.


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

end of thread, other threads:[~2015-09-27 11:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-13 20:17 [Bug locale/18960] New: s390: _nl_locale_subfreeres uses larl opcode on misaligned symbol koriakin at 0x04 dot net
2015-09-27 11:39 ` [Bug locale/18960] " koriakin at 0x04 dot net

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