From: Alan Modra <amodra@bigpond.net.au>
To: Dave Korn <dave.korn@artimi.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] Make obj_sec_set_private_data into a format_ops member
Date: Tue, 02 May 2006 10:37:00 -0000 [thread overview]
Message-ID: <20060502103700.GM11597@bubble.grove.modra.org> (raw)
In-Reply-To: <01d101c66dd1$e92c39e0$a501a8c0@CAM.ARTIMI.COM>
On Tue, May 02, 2006 at 11:19:35AM +0100, Dave Korn wrote:
> objects. It's certainly not necessary to call the hook for those other
> formats, and indeed is not just superfluous but can also be actually
> incorrect; for instance it leads to a null pointer dereference on cygwin.
How?
> My patch preserves existing behaviour in non-multi-obj, fixes incorrect
Yeah, I know. Your patch is good, but I'm going to rip out
obj_sec_set_private_data completely. Here's a preview. I haven't
finished a regression test yet, so things might need to change.
Especially if I run into your NULL deref.
Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.91
diff -u -p -r1.91 section.c
--- bfd/section.c 16 Mar 2006 12:20:16 -0000 1.91
+++ bfd/section.c 2 May 2006 06:58:14 -0000
@@ -964,7 +964,6 @@ DESCRIPTION
asection *
bfd_make_section_old_way (bfd *abfd, const char *name)
{
- struct section_hash_entry *sh;
asection *newsect;
if (abfd->output_has_begun)
@@ -974,30 +973,37 @@ bfd_make_section_old_way (bfd *abfd, con
}
if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
- return bfd_abs_section_ptr;
-
- if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
- return bfd_com_section_ptr;
-
- if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
- return bfd_und_section_ptr;
-
- if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
- return bfd_ind_section_ptr;
+ newsect = bfd_abs_section_ptr;
+ else if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
+ newsect = bfd_com_section_ptr;
+ else if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
+ newsect = bfd_und_section_ptr;
+ else if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
+ newsect = bfd_ind_section_ptr;
+ else
+ {
+ struct section_hash_entry *sh;
- sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
- if (sh == NULL)
- return NULL;
+ sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
+ if (sh == NULL)
+ return NULL;
- newsect = &sh->section;
- if (newsect->name != NULL)
- {
- /* Section already exists. */
- return newsect;
+ newsect = &sh->section;
+ if (newsect->name != NULL)
+ {
+ /* Section already exists. */
+ return newsect;
+ }
+
+ newsect->name = name;
+ return bfd_section_init (abfd, newsect);
}
- newsect->name = name;
- return bfd_section_init (abfd, newsect);
+ /* Call new_section_hook when "creating" the standard abs, com, und
+ and ind sections to tack on format specific section data. */
+ if (! BFD_SEND (abfd, _new_section_hook, (abfd, newsect)))
+ return NULL;
+ return newsect;
}
/*
Index: gas/config/obj-elf.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.h,v
retrieving revision 1.28
diff -u -p -r1.28 obj-elf.h
--- gas/config/obj-elf.h 20 Sep 2005 18:24:45 -0000 1.28
+++ gas/config/obj-elf.h 2 May 2006 06:58:20 -0000
@@ -134,13 +134,6 @@ int elf_s_get_other (symbolS *);
extern asection *gdb_section;
-#ifndef obj_sec_set_private_data
-#define obj_sec_set_private_data(B, S) \
- if (! BFD_SEND ((B), _new_section_hook, ((B), (S)))) \
- as_fatal (_("can't allocate ELF private section data: %s"), \
- bfd_errmsg (bfd_get_error ()))
-#endif
-
#ifndef obj_frob_file
#define obj_frob_file elf_frob_file
#endif
Index: gas/subsegs.c
===================================================================
RCS file: /cvs/src/src/gas/subsegs.c,v
retrieving revision 1.28
diff -u -p -r1.28 subsegs.c
--- gas/subsegs.c 1 May 2006 05:41:40 -0000 1.28
+++ gas/subsegs.c 2 May 2006 06:58:18 -0000
@@ -244,10 +174,6 @@ subseg_get (const char *segname, int for
else
secptr = bfd_make_section_anyway (stdoutput, segname);
-#ifdef obj_sec_set_private_data
- obj_sec_set_private_data (stdoutput, secptr);
-#endif
-
seginfo = seg_info (secptr);
if (! seginfo)
{
--
Alan Modra
IBM OzLabs - Linux Technology Centre
next prev parent reply other threads:[~2006-05-02 10:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <00e801c66c8f$55c9f5e0$a501a8c0@CAM.ARTIMI.COM>
2006-05-02 2:15 ` Alan Modra
2006-05-02 10:19 ` Dave Korn
2006-05-02 10:37 ` Alan Modra [this message]
2006-05-02 10:55 ` Dave Korn
2006-05-02 11:37 ` Alan Modra
2006-05-02 13:34 ` Dave Korn
2006-05-03 14:20 ` Delete obj_sec_set_private_data Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060502103700.GM11597@bubble.grove.modra.org \
--to=amodra@bigpond.net.au \
--cc=binutils@sourceware.org \
--cc=dave.korn@artimi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).