Re: svn commit: r269143 - head/usr.bin/elfdump

2014-07-31 Thread Ed Maste
On 26 July 2014 16:00, Ian Lepore i...@freebsd.org wrote:
 + case EM_ARM:
 + switch (sht) {
 + case 0x7001: return SHT_ARM_EXIDX;
 + case 0x7002: return SHT_ARM_PREEMPTMAP;
 + case 0x7003: return SHT_ARM_ATTRIBUTES;
 + case 0x7004: return SHT_ARM_DEBUGOVERLAY;
 + case 0x7005: return SHT_ARM_OVERLAYSECTION;
 + }
 + break;
   case EM_MIPS:
   switch (sht) {
   case 0x700d: return SHT_MIPS_OPTIONS;


 I'm curious why this code is all full of 0x numbers when there
 are named constants defined for all this stuff.

I don't think there's a good reason for it.  It seems to have just
evolved that way after sh_types() and d_tags() switched from an array
of names, when the first non-contiguous entries were added.  In
r269338 I've replaced the constants with #defines that exist.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r269143 - head/usr.bin/elfdump

2014-07-26 Thread Andreas Tobler
Author: andreast
Date: Sat Jul 26 19:44:45 2014
New Revision: 269143
URL: http://svnweb.freebsd.org/changeset/base/269143

Log:
  Further improvements on elfdump, to follow up r269092:
  
  - Add ARM specific section header types.
  - Add SHT_GNU_HASH section header type.
  - Improve reporting of undefined tags in d_tags.
  - Add DT_GNU_HASH tag.
  
  Reviewed by:  emaste

Modified:
  head/usr.bin/elfdump/elfdump.c

Modified: head/usr.bin/elfdump/elfdump.c
==
--- head/usr.bin/elfdump/elfdump.c  Sat Jul 26 19:27:34 2014
(r269142)
+++ head/usr.bin/elfdump/elfdump.c  Sat Jul 26 19:44:45 2014
(r269143)
@@ -167,7 +167,10 @@ static int elf64_offsets[] = {
 
 /* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#tag_encodings */
 static const char *
-d_tags(u_int64_t tag) {
+d_tags(u_int64_t tag)
+{
+   static char unknown_tag[48];
+
switch (tag) {
case 0: return DT_NULL;
case 1: return DT_NEEDED;
@@ -215,6 +218,7 @@ d_tags(u_int64_t tag) {
case 0x6dfe: return DT_SYMINSZ;
case 0x6dff: return DT_SYMINENT (DT_VALRNGHI);
case 0x6e00: return DT_ADDRRNGLO;
+   case 0x6ef5: return DT_GNU_HASH;
case 0x6ef8: return DT_GNU_CONFLICT;
case 0x6ef9: return DT_GNU_LIBLIST;
case 0x6efa: return DT_SUNW_CONFIG;
@@ -236,8 +240,10 @@ d_tags(u_int64_t tag) {
case 0x7ffd: return DT_SUNW_AUXILIARY;
case 0x7ffe: return DT_SUNW_USED;
case 0x7fff: return DT_SUNW_FILTER;
-   default: return ERROR: TAG NOT DEFINED;
}
+   snprintf(unknown_tag, sizeof(unknown_tag),
+   ERROR: TAG NOT DEFINED -- tag 0x%jx, (uintmax_t)tag);
+   return (unknown_tag);
 }
 
 static const char *
@@ -334,6 +340,7 @@ sh_types(uint64_t machine, uint64_t sht)
switch (sht) {
case 0x6ff0: return XXX:VERSYM;
case 0x6ff4: return SHT_SUNW_dof;
+   case 0x6ff6: return SHT_GNU_HASH;
case 0x6ff7: return SHT_GNU_LIBLIST;
case 0x6ffc: return XXX:VERDEF;
case 0x6ffd: return SHT_SUNW(GNU)_verdef;
@@ -347,6 +354,15 @@ sh_types(uint64_t machine, uint64_t sht)
} else if (sht  0x8000) {
/* 0x7000-0x7fff processor-specific semantics */
switch (machine) {
+   case EM_ARM:
+   switch (sht) {
+   case 0x7001: return SHT_ARM_EXIDX;
+   case 0x7002: return SHT_ARM_PREEMPTMAP;
+   case 0x7003: return SHT_ARM_ATTRIBUTES;
+   case 0x7004: return SHT_ARM_DEBUGOVERLAY;
+   case 0x7005: return SHT_ARM_OVERLAYSECTION;
+   }
+   break;
case EM_MIPS:
switch (sht) {
case 0x700d: return SHT_MIPS_OPTIONS;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r269143 - head/usr.bin/elfdump

2014-07-26 Thread Ian Lepore
On Sat, 2014-07-26 at 19:44 +, Andreas Tobler wrote:
 Author: andreast
 Date: Sat Jul 26 19:44:45 2014
 New Revision: 269143
 URL: http://svnweb.freebsd.org/changeset/base/269143
 
 Log:
   Further improvements on elfdump, to follow up r269092:
   
   - Add ARM specific section header types.
   - Add SHT_GNU_HASH section header type.
   - Improve reporting of undefined tags in d_tags.
   - Add DT_GNU_HASH tag.
   
   Reviewed by:emaste
 
 Modified:
   head/usr.bin/elfdump/elfdump.c
 
 Modified: head/usr.bin/elfdump/elfdump.c
 ==
 --- head/usr.bin/elfdump/elfdump.cSat Jul 26 19:27:34 2014
 (r269142)
 +++ head/usr.bin/elfdump/elfdump.cSat Jul 26 19:44:45 2014
 (r269143)
 @@ -167,7 +167,10 @@ static int elf64_offsets[] = {
  
  /* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#tag_encodings 
 */
  static const char *
 -d_tags(u_int64_t tag) {
 +d_tags(u_int64_t tag)
 +{
 + static char unknown_tag[48];
 +
   switch (tag) {
   case 0: return DT_NULL;
   case 1: return DT_NEEDED;
 @@ -215,6 +218,7 @@ d_tags(u_int64_t tag) {
   case 0x6dfe: return DT_SYMINSZ;
   case 0x6dff: return DT_SYMINENT (DT_VALRNGHI);
   case 0x6e00: return DT_ADDRRNGLO;
 + case 0x6ef5: return DT_GNU_HASH;
   case 0x6ef8: return DT_GNU_CONFLICT;
   case 0x6ef9: return DT_GNU_LIBLIST;
   case 0x6efa: return DT_SUNW_CONFIG;
 @@ -236,8 +240,10 @@ d_tags(u_int64_t tag) {
   case 0x7ffd: return DT_SUNW_AUXILIARY;
   case 0x7ffe: return DT_SUNW_USED;
   case 0x7fff: return DT_SUNW_FILTER;
 - default: return ERROR: TAG NOT DEFINED;
   }
 + snprintf(unknown_tag, sizeof(unknown_tag),
 + ERROR: TAG NOT DEFINED -- tag 0x%jx, (uintmax_t)tag);
 + return (unknown_tag);
  }
  
  static const char *
 @@ -334,6 +340,7 @@ sh_types(uint64_t machine, uint64_t sht)
   switch (sht) {
   case 0x6ff0: return XXX:VERSYM;
   case 0x6ff4: return SHT_SUNW_dof;
 + case 0x6ff6: return SHT_GNU_HASH;
   case 0x6ff7: return SHT_GNU_LIBLIST;
   case 0x6ffc: return XXX:VERDEF;
   case 0x6ffd: return SHT_SUNW(GNU)_verdef;
 @@ -347,6 +354,15 @@ sh_types(uint64_t machine, uint64_t sht)
   } else if (sht  0x8000) {
   /* 0x7000-0x7fff processor-specific semantics */
   switch (machine) {
 + case EM_ARM:
 + switch (sht) {
 + case 0x7001: return SHT_ARM_EXIDX;
 + case 0x7002: return SHT_ARM_PREEMPTMAP;
 + case 0x7003: return SHT_ARM_ATTRIBUTES;
 + case 0x7004: return SHT_ARM_DEBUGOVERLAY;
 + case 0x7005: return SHT_ARM_OVERLAYSECTION;
 + }
 + break;
   case EM_MIPS:
   switch (sht) {
   case 0x700d: return SHT_MIPS_OPTIONS;
 

I'm curious why this code is all full of 0x numbers when there
are named constants defined for all this stuff.

-- Ian



___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r269143 - head/usr.bin/elfdump

2014-07-26 Thread Andreas Tobler

On 26.07.14 22:00, Ian Lepore wrote:

On Sat, 2014-07-26 at 19:44 +, Andreas Tobler wrote:

Author: andreast
Date: Sat Jul 26 19:44:45 2014
New Revision: 269143
URL: http://svnweb.freebsd.org/changeset/base/269143

Log:
   Further improvements on elfdump, to follow up r269092:

   - Add ARM specific section header types.
   - Add SHT_GNU_HASH section header type.
   - Improve reporting of undefined tags in d_tags.
   - Add DT_GNU_HASH tag.

   Reviewed by: emaste

Modified:
   head/usr.bin/elfdump/elfdump.c

Modified: head/usr.bin/elfdump/elfdump.c
==
--- head/usr.bin/elfdump/elfdump.c  Sat Jul 26 19:27:34 2014
(r269142)
+++ head/usr.bin/elfdump/elfdump.c  Sat Jul 26 19:44:45 2014
(r269143)
@@ -167,7 +167,10 @@ static int elf64_offsets[] = {

  /* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#tag_encodings */
  static const char *
-d_tags(u_int64_t tag) {
+d_tags(u_int64_t tag)
+{
+   static char unknown_tag[48];
+
switch (tag) {
case 0: return DT_NULL;
case 1: return DT_NEEDED;
@@ -215,6 +218,7 @@ d_tags(u_int64_t tag) {
case 0x6dfe: return DT_SYMINSZ;
case 0x6dff: return DT_SYMINENT (DT_VALRNGHI);
case 0x6e00: return DT_ADDRRNGLO;
+   case 0x6ef5: return DT_GNU_HASH;
case 0x6ef8: return DT_GNU_CONFLICT;
case 0x6ef9: return DT_GNU_LIBLIST;
case 0x6efa: return DT_SUNW_CONFIG;
@@ -236,8 +240,10 @@ d_tags(u_int64_t tag) {
case 0x7ffd: return DT_SUNW_AUXILIARY;
case 0x7ffe: return DT_SUNW_USED;
case 0x7fff: return DT_SUNW_FILTER;
-   default: return ERROR: TAG NOT DEFINED;
}
+   snprintf(unknown_tag, sizeof(unknown_tag),
+   ERROR: TAG NOT DEFINED -- tag 0x%jx, (uintmax_t)tag);
+   return (unknown_tag);
  }

  static const char *
@@ -334,6 +340,7 @@ sh_types(uint64_t machine, uint64_t sht)
switch (sht) {
case 0x6ff0: return XXX:VERSYM;
case 0x6ff4: return SHT_SUNW_dof;
+   case 0x6ff6: return SHT_GNU_HASH;
case 0x6ff7: return SHT_GNU_LIBLIST;
case 0x6ffc: return XXX:VERDEF;
case 0x6ffd: return SHT_SUNW(GNU)_verdef;
@@ -347,6 +354,15 @@ sh_types(uint64_t machine, uint64_t sht)
} else if (sht  0x8000) {
/* 0x7000-0x7fff processor-specific semantics */
switch (machine) {
+   case EM_ARM:
+   switch (sht) {
+   case 0x7001: return SHT_ARM_EXIDX;
+   case 0x7002: return SHT_ARM_PREEMPTMAP;
+   case 0x7003: return SHT_ARM_ATTRIBUTES;
+   case 0x7004: return SHT_ARM_DEBUGOVERLAY;
+   case 0x7005: return SHT_ARM_OVERLAYSECTION;
+   }
+   break;
case EM_MIPS:
switch (sht) {
case 0x700d: return SHT_MIPS_OPTIONS;



I'm curious why this code is all full of 0x numbers when there
are named constants defined for all this stuff.


No clue. I continued the used pattern.
It would make more sense to use the defines from elf_common.h, less 
error prone.


Andreas

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org