Alignment of special common variables
Galit Heller
Galit.Heller@nsc.com
Wed Jan 14 19:44:00 GMT 2004
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.
More information about the Binutils
mailing list