{
bound_minimal_symbol bound_msym = {msymbol, objfile};
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- CORE_ADDR addr = BMSYMBOL_VALUE_ADDRESS (bound_msym);
struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
enum minimal_symbol_type type = MSYMBOL_TYPE (msymbol);
CORE_ADDR pc;
+ bool is_tls = (section != NULL
+ && section->the_bfd_section->flags & SEC_THREAD_LOCAL);
+
+ /* Addresses of TLS symbols are really offsets into a
+ per-objfile/per-thread storage block. */
+ CORE_ADDR addr = (is_tls
+ ? MSYMBOL_VALUE_RAW_ADDRESS (bound_msym.minsym)
+ : BMSYMBOL_VALUE_ADDRESS (bound_msym));
+
/* The minimal symbol might point to a function descriptor;
resolve it to the actual code address instead. */
pc = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, ¤t_target);
if (overlay_debugging)
addr = symbol_overlayed_address (addr, section);
- if (section && section->the_bfd_section->flags & SEC_THREAD_LOCAL)
+ if (is_tls)
{
/* Skip translation if caller does not need the address. */
if (address_p != NULL)