This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ 18960] setlocale.c: Mark *_used symbols as unaligned.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Marcin KoÅcielnicki <koriakin at 0x04 dot net>, Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org, mike dot milinkovich at eclipse dot org
- Date: Mon, 28 Sep 2015 13:34:02 -0400
- Subject: Re: [PATCH][BZ 18960] setlocale.c: Mark *_used symbols as unaligned.
- Authentication-results: sourceware.org; auth=none
- References: <1443360385-20079-1-git-send-email-koriakin at 0x04 dot net> <56093DC0 dot 3080802 at redhat dot com> <56094C10 dot 5040203 at redhat dot com> <56095AB2 dot 5090305 at 0x04 dot net>
On 09/28/2015 11:20 AM, Marcin KoÅcielnicki wrote:
>> A function address would have all the requirements for alignment that you would
>> need to avoid this problem.
>
> Sorry, I don't get what you're talking about.
This is an artificial address of 1, which is why it is violating assumptions in
the s390x implementation. If the address had been that of a function, we would
not have seen this failure.
We might add a way to create valid addresses from flags and vice versa using a
macro from libc-symbols.h as Mike suggests.
Totally untested:
sysdeps/generic/libc-symbols.h
/* On a generic machine any symbol address is valid. */
#define FLAGS_TO_SYMADDR(val) (val)
#define SYMADDR_TO_FLAGS(val) (val)
#include_next <libc-symbols.h>
sysdeps/s390/libc-symbols.h
/* On s390 a symbol address must be aligned to X. Therefore if we hide
flags in a symbol address we loose the lowest bits for flags. */
#define FLAGS_TO_SYMADDR(val) (val << X)
#define SYMADDR_TO_FLAGS(val) (val >> X)
#include_next <libc-symbols.h>
locale/localeinfo.h:
/* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */
#define _NL_CURRENT_DEFINE(category) \
__thread struct __locale_data *const *_nl_current_##category \
attribute_hidden = &_nl_global_locale.__locales[category]; \
asm (".globl " __SYMBOL_PREFIX "_nl_current_" #category "_used\n" \
_NL_CURRENT_DEFINE_ABS (_nl_current_##category##_used,
FLAGS_TO_SYMADDR (1)));
...
locale/uselocale.c:
# define DEFINE_CATEGORY(category, category_name, items, a) \
{ \
extern char _nl_current_##category##_used; \
weak_extern (_nl_current_##category##_used) \
weak_extern (_nl_current_##category) \
if (SYMADDR_TO_FLAGS(&_nl_current_##category##_used) != 0) \
_nl_current_##category = &locobj->__locales[category]; \
}
Does that make sense?
Cheers,
Carlos.