public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* section indices for special sections
@ 2013-01-02 19:11 Tom Tromey
  2013-01-07 14:01 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2013-01-02 19:11 UTC (permalink / raw)
  To: Binutils Development

I was hoping to use the BFD section index in gdb to identify a section,
to remove some redundant information from symbols and also shrink their
size.

However, I discovered that the various special sections like *ABS* are
global, not per-BFD, and their 'index' fields are not useful.

I wonder what you think of the appended patch.  It gives negative
indices to these special sections.  If it seems ok I would either have
gdb look at the size of the std_section array, or introduce a new define
so gdb can know how many special sections to expect.

I regression tested this against ld, gas, and binutils, but not gdb.
I suspect it may have issues there, so I would only want to apply it
after finishing my gdb patch series and testing this.

Tom

	* section.c (BFD_FAKE_SECTION): Set 'index' field.
        * bfd-in2.h: Rebuild.

diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index ceacf8f..a5ff702 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1693,7 +1693,7 @@ extern asection _bfd_std_section[4];
 
 #define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX)                   \
   /* name, id,  index, next, prev, flags, user_set_vma,            */  \
-  { NAME,  IDX, 0,     NULL, NULL, FLAGS, 0,                           \
+  { NAME,  IDX, - IDX - 1,     NULL, NULL, FLAGS, 0,                   \
                                                                        \
   /* linker_mark, linker_has_input, gc_mark, decompress_status,    */  \
      0,           0,                1,       0,                        \
diff --git a/bfd/section.c b/bfd/section.c
index a59bc71..6a417d1 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -663,7 +663,7 @@ CODE_FRAGMENT
 .
 .#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX)			\
 .  {* name, id,  index, next, prev, flags, user_set_vma,            *}	\
-.  { NAME,  IDX, 0,     NULL, NULL, FLAGS, 0,				\
+.  { NAME,  IDX, - IDX - 1,     NULL, NULL, FLAGS, 0,			\
 .									\
 .  {* linker_mark, linker_has_input, gc_mark, decompress_status,    *}	\
 .     0,           0,                1,       0,			\
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: section indices for special sections
  2013-01-02 19:11 section indices for special sections Tom Tromey
@ 2013-01-07 14:01 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2013-01-07 14:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Binutils Development

On Wed, Jan 02, 2013 at 12:10:57PM -0700, Tom Tromey wrote:
> --- a/bfd/section.c
> +++ b/bfd/section.c
> @@ -663,7 +663,7 @@ CODE_FRAGMENT
>  .
>  .#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX)			\
>  .  {* name, id,  index, next, prev, flags, user_set_vma,            *}	\
> -.  { NAME,  IDX, 0,     NULL, NULL, FLAGS, 0,				\
> +.  { NAME,  IDX, - IDX - 1,     NULL, NULL, FLAGS, 0,			\
>  .									\
>  .  {* linker_mark, linker_has_input, gc_mark, decompress_status,    *}	\
>  .     0,           0,                1,       0,			\

I think this is probably OK as far as ld is concerned.  Please be sure
to regression test this on ARM and PowerPC64.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-07 14:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-02 19:11 section indices for special sections Tom Tromey
2013-01-07 14:01 ` 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).