PATCH: Don't allow ia64 unwind section to point to section in different files
Quoted 8 lines · David Mosberger
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · H. J. Lu
However, there still seems to be a binutils issues here: if this is something binutils cannot properly support, it should issue an error, not silently generate wrong code, no?
HJ> I will see what I can do.
When weak functions are used on ia64, part of the unwind section may point to the strong definition in a different file. This will lead to wrong unwind info. Basically, on ia64, we have to use comdat to get the right unwind info. This patch will check it.
H.J.
---
2005-05-13 H.J. Lu <[email protected]>
* elfxx-ia64.c (elfNN_ia64_relocate_section): Don't allow unwind section to point to section in different files.
elfxx-ia64.c renamed from elfxx-ia64.c.weak +21 -0
@@ -4151,6 +4151,27 @@ elfNN_ia64_relocate_section (output_bfd, value += rel->r_addend; dynamic_symbol_p =elfNN_ia64_dynamic_symbol_p (h, info, r_type); +/* The unwind section and the corresponding text section have +to come from the same file. When the strong function overides +a weak function, part of the unwind section may point to the +wrong place. */ +if (h + && (h->root.type = bfd_link_hash_defined + || h->root.type = bfd_link_hash_defweak) + && (elf_section_data (input_section)->this_hdr.sh_type + =SHT_IA_64_UNWIND ) + && input_section->owner != h->root.u.def.section->owner) + { + (*_bfd_error_handler) + (_ ("%B: unwind section `%A' points to symbol `%s' defined in section '%A' in %B" ), + input_bfd, input_section, h->root.u.def.section, + h->root.u.def.section->owner, + h ? h->root.root.string + :bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sym_sec)); + ret_val = FALSE; +continue ; + } +switch (r_type) {case R_IA64_NONE :
Quoted 7 lines · H. J. Lu
Quoted 6 lines · David Mosberger
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · H. J. Lu
However, there still seems to be a binutils issues here: if this is something binutils cannot properly support, it should issue an error, not silently generate wrong code, no?
Quoted 9 lines
Quoted 2 lines
HJ> I will see what I can do.
When weak functions are used on ia64, part of the unwind section may point to the strong definition in a different file. This will lead to wrong unwind info. Basically, on ia64, we have to use comdat to get the right unwind info. This patch will check it.
Well, it isn't very useful. The problem is libc.a has many weak functions and user can override them. My patch will make it impossible on ia64. I guess we may have to live with the imperfect unwind info when weak functions are used. The unwinder may have to deal with it.
H.J.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · H. J. Lu
HJ> Well, it isn't very useful. The problem is libc.a has many weak HJ> functions and user can override them. My patch will make it HJ> impossible on ia64. I guess we may have to live with the HJ> imperfect unwind info when weak functions are used. The unwinder HJ> may have to deal with it.
Huh? How do you propose it deal with it?
Wrong unwind info will break exception handling. I don't think that's acceptable.
--david
Quoted 8 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · H. J. Lu
HJ> Well, it isn't very useful. The problem is libc.a has many weak HJ> functions and user can override them. My patch will make it HJ> impossible on ia64. I guess we may have to live with the HJ> imperfect unwind info when weak functions are used. The unwinder HJ> may have to deal with it.
Quoted 4 lines
Huh? How do you propose it deal with it?
Wrong unwind info will break exception handling. I don't think that's acceptable.
Since the weak function is still in the executable, its unwind info is also there. That is what you see in kernel.
H.J.