[PATCH] ld.so: handle STT_COMMON symbols
Joakim Tjernlund
joakim.tjernlund at transmode.se
Mon Oct 8 08:11:29 UTC 2007
On Mon, 2007-10-08 at 09:10 +0200, Carmelo AMOROSO wrote:
> Hi Folks,
> as reported into glibc bug #5104
> (http://sourceware.org/bugzilla/show_bug.cgi?id=5104)
>
> "
>
> The loader does not handle symbols with the STT_COMMON type.
>
> We (the Binutils project) are currently examining the possibilty of having the
> linker set the type of common symbols to STT_COMMON instead of STT_OBJECT. See
> the thread starting here:
>
> http://sources.redhat.com/ml/binutils/2007-10/msg00046.html
>
> It was pointed out however that the loader would not currently handle such
> symbols properly, so for now, the patch is not going to be applied. It would be
> good however if the loader could process such symbols, so that we might then
> allow the linker to generate them.
>
> Cheers
> Nick Clifton
>
> "
>
> the uclibc ld.so has to be updated to handle this kind of symbols with next binutils release.
> This patch does it.
>
> Regards,
> Carmelo
>
>
> plain text document attachment (dl_find_hash-stt_common.patch)
> Hadle STT_COMMON symbols too. Following binutils release
> will set the type of common symbols to STT_COMMON
> instead of STT_OBJECTS, so the dynamic linker needs
> to handle this type os symbols too.
> Same changes have been added to glibc (See: bugzilla #5104).
> This patch ensures the uclibc will work with later bintuils.
>
> Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
>
> --- uClibc-trunk/ldso/ldso/dl-hash.c 2007-10-08 08:54:40.020926000 +0200
> +++ uClibc-trunk-st/ldso/ldso/dl-hash.c 2007-10-08 08:59:19.892237000 +0200
> @@ -177,7 +177,12 @@ char *_dl_find_hash(const char *name, st
> continue;
> if (sym->st_value == 0)
> continue;
> - if (ELF_ST_TYPE(sym->st_info) > STT_FUNC)
> + if (ELF_ST_TYPE(sym->st_info) > STT_FUNC
> + && ELF_ST_TYPE(sym->st_info) != STT_COMMON)
> + /* Ignore all but STT_NOTYPE, STT_OBJECT, STT_FUNC
> + * and STT_COMMON entries since these are no
> + * code/data definitions
> + */
> continue;
> if (_dl_strcmp(strtab + sym->st_name, name) != 0)
> continue;
I am good with this change. One question though: I don't think the
STT_SECTION and STT_FILE are present in a relocatable object. If this
is true(needs to be checked), then the above if stmt can be changed to:
#define STT_RELOC_MAX STT_TLS
or
#define STT_RELOC_MAX STT_COMMON
if (ELF_ST_TYPE(sym->st_info) > STT_RELOC_MAX)
or if the above assumption is true only for STT_FILE
if (ELF_ST_TYPE(sym->st_info) > STT_RELOC_MAX || ELF_ST_TYPE(sym->st_info) == STT_SECTION)
More information about the uClibc
mailing list