- if (! tramp_msym)
- error ("Cannot convert code address %s to function pointer:\n"
- "couldn't find trampoline named '%s.plt'.",
- paddr_nz (addr), func_name);
+ if (! tramp_msym.minsym)
+ {
+ CORE_ADDR ptrval;
+
+ /* No PLT entry found. Mask off the upper bits of the address
+ to make a pointer. As noted in the warning to the user
+ below, this value might be useful if converted back into
+ an address by GDB, but will otherwise, almost certainly,
+ be garbage.
+
+ Using this masked result does seem to be useful
+ in gdb.cp/cplusfuncs.exp in which ~40 FAILs turn into
+ PASSes. These results appear to be correct as well.
+
+ We print a warning here so that the user can make a
+ determination about whether the result is useful or not. */
+ ptrval = addr & 0xffff;
+
+ warning (_("Cannot convert code address %s to function pointer:\n"
+ "couldn't find trampoline named '%s.plt'.\n"
+ "Returning pointer value %s instead; this may produce\n"
+ "a useful result if converted back into an address by GDB,\n"
+ "but will most likely not be useful otherwise."),
+ paddress (gdbarch, addr), func_name,
+ paddress (gdbarch, ptrval));
+
+ addr = ptrval;