[PATCH] include/libbb.h: declare messages with ALIGN1
Aurelien Jarno
aurelien at aurel32.net
Tue Jul 17 20:40:54 UTC 2012
On Mon, Jul 16, 2012 at 06:54:38PM +0400, Michael Tokarev wrote:
> On 16.07.2012 12:56, Aurelien Jarno wrote:
> > Some messages strings are defined with ALIGN1 in libbb/messages.c
> > to make sure strings are not aligned and thus to save some bytes. The
> > corresponding declaration in include/libbb.h should also use ALIGN1,
> > otherwise the compiler may assume they are aligned and generate wrong
> > code to access them. This is the case on at least s390x.
> >
> > Signed-off-by: Aurelien Jarno <aurelien at aurel32.net>
> > ---
> > include/libbb.h | 36 ++++++++++++++++++------------------
> > 1 file changed, 18 insertions(+), 18 deletions(-)
> >
> > diff --git a/include/libbb.h b/include/libbb.h
> > index 322a28c..f22e58e 100644
> > --- a/include/libbb.h
> > +++ b/include/libbb.h
> > @@ -1612,8 +1612,8 @@ unsigned get_cpu_count(void) FAST_FUNC;
> > char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
> >
> >
> > -extern const char bb_uuenc_tbl_base64[];
> > -extern const char bb_uuenc_tbl_std[];
> > +extern const char bb_uuenc_tbl_base64[] ALIGN1;
> > +extern const char bb_uuenc_tbl_std[] ALIGN1;
>
> I wonder whenever changing all these from arrays to
> pointers is a good idea? Compiler should not assume
> any alignments about pointer to char, unlike an array,
> I think.
>
> I mean,
>
> -extern const char bb_uuenc_tbl_base64[];
> +extern const char *bb_uuenc_tbl_base64;
>
> Besides, this, and a few others (bb_hexdigits_upcase),
> might be better without alignment.
>
I confirm this solution also works on s390x, but it implies also
changing the definitions of the strings in libbb/messages.c, otherwise
GCC is unhappy about the change.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien at aurel32.net http://www.aurel32.net
More information about the busybox
mailing list