This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Use symbolic constants instead of magic numbers with add_data_entry()


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=477bdd393c8145ad44899cb4681d57a61c82aad3

commit 477bdd393c8145ad44899cb4681d57a61c82aad3
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Jun 2 13:46:58 2016 +0000

    Use symbolic constants instead of magic numbers with add_data_entry()
    
    Use symbolic constants from include/coff/internal.h instead of magic numbers
    with add_data_entry()
    
    bfd/ChangeLog:
    
    2017-04-02  Jon Turney  <jon.turney@dronecode.org.uk>
    
    	(_bfd_XXi_swap_aouthdr_out): For clarity, use defines rather than
    	numbers for DataDirectory entry indicies passed to
    	add_data_entry().

Diff:
---
 bfd/ChangeLog  |  6 ++++++
 bfd/peXXigen.c | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 46d92a0..4703b21 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-02  Jon Turney  <jon.turney@dronecode.org.uk>
+
+	(_bfd_XXi_swap_aouthdr_out): For clarity, use defines rather than
+	numbers for DataDirectory entry indicies passed to
+	add_data_entry().
+
 2017-04-04  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* elf.c (get_program_header_size): Add a GNU_MBIND segment for
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 27e576c..eb9c879 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -675,9 +675,9 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out)
 
   extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
 
-  add_data_entry (abfd, extra, 0, ".edata", ib);
-  add_data_entry (abfd, extra, 2, ".rsrc", ib);
-  add_data_entry (abfd, extra, 3, ".pdata", ib);
+  add_data_entry (abfd, extra, PE_EXPORT_TABLE, ".edata", ib);
+  add_data_entry (abfd, extra, PE_RESOURCE_TABLE, ".rsrc", ib);
+  add_data_entry (abfd, extra, PE_EXCEPTION_TABLE, ".pdata", ib);
 
   /* In theory we do not need to call add_data_entry for .idata$2 or
      .idata$5.  It will be done in bfd_coff_final_link where all the
@@ -695,7 +695,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out)
   if (extra->DataDirectory[PE_IMPORT_TABLE].VirtualAddress == 0)
     /* Until other .idata fixes are made (pending patch), the entry for
        .idata is needed for backwards compatibility.  FIXME.  */
-    add_data_entry (abfd, extra, 1, ".idata", ib);
+    add_data_entry (abfd, extra, PE_IMPORT_TABLE, ".idata", ib);
 
   /* For some reason, the virtual size (which is what's set by
      add_data_entry) for .reloc is not the same as the size recorded
@@ -703,7 +703,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out)
      but since it's the best we've got, use it.  It does do the right
      thing for .pdata.  */
   if (pe->has_reloc_section)
-    add_data_entry (abfd, extra, 5, ".reloc", ib);
+    add_data_entry (abfd, extra, PE_BASE_RELOCATION_TABLE, ".reloc", ib);
 
   {
     asection *sec;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]