This is the mail archive of the 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: [GOLD] How can I add a undefined symbol in target implementation, not by "-u SYM" from command line ?

2012/8/13 Ian Lance Taylor <>:
> On Mon, Aug 13, 2012 at 3:25 AM, Jiong WANG <> wrote:
>>   How can I predefine a undefined symbol in target implementation?
>>   actually, I am porting gold for tilegx, and our arch's tls
>> implementation requires predefiniation of "_tls_get_addr" because the
>> assembler generate relocation which use this symbol implicitly.
>>    I know there are interfaces,  "define_in_output_data/segment" to
>> predefined symbol with value, but there is no interface to predefine
>> "undefined" symbol ?
>>    gold linker do support this by command line "-u SYMBOL",  but it's
>> a compile time decision not link time.
>>    currently, I managed to support this by the following ugly code:
>>     options::parse_set(NULL, "_tls_get_addr",
>> (gold::options::String_set*)&parameters->options().undefined());
>>    which is bad, so, could anyone give me some suggestion on this?
> I assume that the symbol is defined somewhere.  You probably want to
> add a do_is_defined_by_abi method to your Target.  See the examples in
> existing targets.

Hi Ian & all, thanks for your suggestion.

I have explored do_is_defined_by_abi, and found it's mostly to avoid
warning, but not for creating such a symbol

do_is_defined_by_abi has one argument of the type "const Symbol*",  so
when it's invoked, that symbol should already existed.

below is my ugly code to create a external symbol which is not from
any object files, but pretend to be

case elfcpp::R_TILEGX_TLS_GD_CALL:

    // FIXME:
    // ugly code to predefine _tls_get_addr
    // should be fixed later
    if (!target->tls_get_addr_sym_defined_) {
      Symbol* sym = NULL;
      options::parse_set(NULL, "__tls_get_addr",
      target->tls_get_addr_sym_defined_ = true;
      sym = symtab->lookup("__tls_get_addr");
    target->make_plt_entry(symtab, layout, symtab->lookup("__tls_get_addr"));

  basically, I want to create a symbol which is neither against
section or segment, just a normally external function symbol.

  above code works when use gcc driver to invoke gold, because
are involved in.

  but it still failed, when use gold directly by:

      tile-ld -shared -o tls.o
      tile-ld: internal error in get_symbol_index, at

  I think there maybe some other graceful and standard way to solve
this problem.

  please feel free to give any suggestion

  thanks very much !


> Ian

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