* Better default for elf_backend_section_from_shdr
@ 2005-03-01 22:41 Zack Weinberg
2005-03-02 3:22 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: Zack Weinberg @ 2005-03-01 22:41 UTC (permalink / raw)
To: binutils
Currently elfxx-target.h defaults elf_backend_section_from_shdr to 0.
This means that if a third-party toolchain (or a toolchain configured
for a different ELF architecture) produces sections with types that
the generic code doesn't know about, the reader won't create entries
for them in the elf_elfsections array. And if other sections refer to
those sections (e.g. via relocations) tools such as objdump and nm
will reject the file as ill-formed.
It seems to make more sense to set elf_backend_section_from_shdr to
_bfd_elf_make_section_from_shdr. This causes such sections to be
treated as generic, which is usually the right thing at least for
inspection purposes. So I would like to apply the appended patch.
Thoughts? Should this be done for the other
elf_backend_section_from_* hooks too?
zw
* elfxx-target.h: Default elf_backend_section_from_shdr to
_bfd_elf_make_section_from_shdr.
===================================================================
Index: bfd/elfxx-target.h
--- bfd/elfxx-target.h 22 Feb 2005 00:50:04 -0000 1.78
+++ bfd/elfxx-target.h 1 Mar 2005 22:39:53 -0000
@@ -326,7 +326,7 @@
#define elf_backend_section_processing 0
#endif
#ifndef elf_backend_section_from_shdr
-#define elf_backend_section_from_shdr 0
+#define elf_backend_section_from_shdr _bfd_elf_make_section_from_shdr
#endif
#ifndef elf_backend_section_flags
#define elf_backend_section_flags 0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Better default for elf_backend_section_from_shdr
2005-03-01 22:41 Better default for elf_backend_section_from_shdr Zack Weinberg
@ 2005-03-02 3:22 ` Alan Modra
2005-03-02 4:12 ` Zack Weinberg
0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2005-03-02 3:22 UTC (permalink / raw)
To: Zack Weinberg; +Cc: binutils
On Tue, Mar 01, 2005 at 02:41:48PM -0800, Zack Weinberg wrote:
> It seems to make more sense to set elf_backend_section_from_shdr to
> _bfd_elf_make_section_from_shdr. This causes such sections to be
> treated as generic, which is usually the right thing at least for
> inspection purposes. So I would like to apply the appended patch.
I agree. Please apply.
> Thoughts? Should this be done for the other
> elf_backend_section_from_* hooks too?
Definitely for elf_backend_section_from_phdr. See the default case in
elf.c:bfd_section_from_phdr. Please clean this up while you're at it,
to call the backend function unconditionally. Same in
bfd_section_from_shdr.
I don't think there is a sensible default for
elf_backend_section_from_bfd_section.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Better default for elf_backend_section_from_shdr
2005-03-02 3:22 ` Alan Modra
@ 2005-03-02 4:12 ` Zack Weinberg
2005-03-02 4:25 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: Zack Weinberg @ 2005-03-02 4:12 UTC (permalink / raw)
To: binutils
Alan Modra <amodra@bigpond.net.au> writes:
> Definitely for elf_backend_section_from_phdr. See the default case in
> elf.c:bfd_section_from_phdr. Please clean this up while you're at it,
> to call the backend function unconditionally. Same in
> bfd_section_from_shdr.
I'm not sure I understand this request. The appended patch does what
I think you meant. Please verify?
zw
* elf.c (bfd_section_from_shdr <default case>):
Call elf_backend_section_from_shdr hook unconditionally, and
return what it returns.
(bfd_section_from_phdr): Similarly, for elf_backend_section_from_phdr.
* elfxx-target.h (elf_backend_section_from_shdr)
(elf_backend_section_from_phdr): Default to
_bfd_elf_make_section_from_shdr and _bfd_elf_make_section_from_phdr
respectively.
===================================================================
Index: bfd/elf.c
--- bfd/elf.c 23 Feb 2005 09:46:48 -0000 1.267
+++ bfd/elf.c 2 Mar 2005 04:08:05 -0000
@@ -2039,9 +2039,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
default:
/* Check for any processor-specific section types. */
- if (bed->elf_backend_section_from_shdr)
- (*bed->elf_backend_section_from_shdr) (abfd, hdr, name);
- break;
+ return bed->elf_backend_section_from_shdr (abfd, hdr, name);
}
return TRUE;
@@ -2379,13 +2377,9 @@ bfd_section_from_phdr (bfd *abfd, Elf_In
return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro");
default:
- /* Check for any processor-specific program segment types.
- If no handler for them, default to making "segment" sections. */
+ /* Check for any processor-specific program segment types. */
bed = get_elf_backend_data (abfd);
- if (bed->elf_backend_section_from_phdr)
- return (*bed->elf_backend_section_from_phdr) (abfd, hdr, index);
- else
- return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "segment");
+ return bed->elf_backend_section_from_phdr (abfd, hdr, index);
}
}
===================================================================
Index: bfd/elfxx-target.h
--- bfd/elfxx-target.h 22 Feb 2005 00:50:04 -0000 1.78
+++ bfd/elfxx-target.h 2 Mar 2005 04:08:05 -0000
@@ -326,13 +326,13 @@
#define elf_backend_section_processing 0
#endif
#ifndef elf_backend_section_from_shdr
-#define elf_backend_section_from_shdr 0
+#define elf_backend_section_from_shdr _bfd_elf_make_section_from_shdr
#endif
#ifndef elf_backend_section_flags
#define elf_backend_section_flags 0
#endif
#ifndef elf_backend_section_from_phdr
-#define elf_backend_section_from_phdr 0
+#define elf_backend_section_from_phdr _bfd_elf_make_section_from_phdr
#endif
#ifndef elf_backend_fake_sections
#define elf_backend_fake_sections 0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Better default for elf_backend_section_from_shdr
2005-03-02 4:12 ` Zack Weinberg
@ 2005-03-02 4:25 ` Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2005-03-02 4:25 UTC (permalink / raw)
To: Zack Weinberg; +Cc: binutils
On Tue, Mar 01, 2005 at 08:12:40PM -0800, Zack Weinberg wrote:
> * elf.c (bfd_section_from_shdr <default case>):
> Call elf_backend_section_from_shdr hook unconditionally, and
> return what it returns.
> (bfd_section_from_phdr): Similarly, for elf_backend_section_from_phdr.
> * elfxx-target.h (elf_backend_section_from_shdr)
> (elf_backend_section_from_phdr): Default to
> _bfd_elf_make_section_from_shdr and _bfd_elf_make_section_from_phdr
> respectively.
OK.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-03-02 4:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-01 22:41 Better default for elf_backend_section_from_shdr Zack Weinberg
2005-03-02 3:22 ` Alan Modra
2005-03-02 4:12 ` Zack Weinberg
2005-03-02 4:25 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).