This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Alignment of special common variables
- From: "Galit Heller" <Galit dot Heller at nsc dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 14 Jan 2004 21:47:53 +0200
- Subject: Alignment of special common variables
Hi,
Our port for NS CR16C defines special common variable sections, in a manner
similar to MIPS's .scommon, using hook functions such as
elf_backend_add_symbol_hook.
We noticed that these special common variables aren't aligned correctly in the
output, and, specifically -with -sort-common, they aren't sorted correctly,
and traced the reason to the following test in elflink.h
function elf_bfd_link_add_symbols:
/* Set the alignment of a common symbol. */
if (isym->st_shndx == SHN_COMMON
&& h->root.type == bfd_link_hash_common)
{
unsigned int align;
align = bfd_log2 (isym->st_value);
if (align > old_alignment
/* Permit an alignment power of zero if an alignment of one
is specified and no other alignments have been specified. */
|| (isym->st_value == 1 && old_alignment == 0))
h->root.u.c.p->alignment_power = align;
else
h->root.u.c.p->alignment_power = old_alignment;
}
Since the section index of these variables is a processor specific section
index, and not SHN_COMMON, the condition isn't true, and thus the special
common variables' alignment isn't set correctly (instead it's set to the
size, by _bfd_generic_link_add_one_symbol).
Has anyone experienced this problem on a platform which supports special
common sections, and has a suggestion how to work around this ?
Regards,
Galit.