This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC/A: Add a bfd hook for defining common symbols


On Wed, Apr 1, 2009 at 12:28 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> The XCOFF linker uses XCOFF_DEF_REGULAR to check whether a symbol
> has a regular definition. ?xcofflink.c:xcoff_post_gc_symbol therefore
> checks for common symbols that were defined by the linker:
>
> ?/* If this is a final link, and the symbol was defined as a common
> ? ? symbol in a regular object file, and there was no definition in
> ? ? any dynamic object, then the linker will have allocated space for
> ? ? the symbol in a common section but the XCOFF_DEF_REGULAR flag
> ? ? will not have been set. ?*/
> ?if (h->root.type == bfd_link_hash_defined
> ? ? ?&& (h->flags & XCOFF_DEF_REGULAR) == 0
> ? ? ?&& (h->flags & XCOFF_REF_REGULAR) != 0
> ? ? ?&& (h->flags & XCOFF_DEF_DYNAMIC) == 0
> ? ? ?&& (bfd_is_abs_section (h->root.u.def.section)
> ? ? ? ? ?|| (h->root.u.def.section->owner->flags & DYNAMIC) == 0))
> ? ?h->flags |= XCOFF_DEF_REGULAR;
>
> But this happens too late for things like xcoff_mark_auto_exports.
>
> We could just put this code in a function and use it instead of testing
> XCOFF_DEF_REGULAR directly. ?That seems a bit messy though, and I don't
> really like this idea of detecting what the linker has done after the fact.
>
> Another alternative is to add a linker emulation hook. ?But we'd
> then be exposing XCOFF_DEF_REGULAR outside BFD, which doesn't seem
> very clean either.

FWIW, ELF linker emulation includes "elf-bfd.h" and uses plenty of
BFD/ELF things. I don't see why you can't do it for XCOFF. You don't
need to access XCOFF_DEF_REGULAR directly from linker. A macro
defined in BFD should work for you.

> We already allocate .dynbss within BFD itself, so what do you think
> about doing the same for common symbols? ?Does the patch below look right,
> or is it overkill?
>

I would prefer a linker emulation hook.



-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]