[GOLD] How can I add a undefined symbol in target implementation, not by "-u SYM" from command line ?
Jiong WANG
wong.kwongyuan@gmail.com
Tue Aug 14 03:39:00 GMT 2012
More information about the Binutils mailing list
Tue Aug 14 03:39:00 GMT 2012
- Previous message (by thread): [GOLD] How can I add a undefined symbol in target implementation, not by "-u SYM" from command line ?
- Next message (by thread): [GOLD] How can I add a undefined symbol in target implementation, not by "-u SYM" from command line ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2012/8/13 Ian Lance Taylor <iant@google.com>: > On Mon, Aug 13, 2012 at 3:25 AM, Jiong WANG <wong.kwongyuan@gmail.com> 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*)¶meters->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", (gold::options::String_set*)¶meters->options().undefined()); symtab->add_undefined_symbols_from_command_line(layout); target->tls_get_addr_sym_defined_ = true; sym = symtab->lookup("__tls_get_addr"); sym->set_in_reg(); } target->make_plt_entry(symtab, layout, symtab->lookup("__tls_get_addr")); break; 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 libc.so are involved in. but it still failed, when use gold directly by: tile-ld -shared -o libtls.so tls.o tile-ld: internal error in get_symbol_index, at ../binutils/gold/output.cc:1031 I think there maybe some other graceful and standard way to solve this problem. please feel free to give any suggestion thanks very much ! --- Regards, WANG.Jiong > > Ian
- Previous message (by thread): [GOLD] How can I add a undefined symbol in target implementation, not by "-u SYM" from command line ?
- Next message (by thread): [GOLD] How can I add a undefined symbol in target implementation, not by "-u SYM" from command line ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list