Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jan 2019 20:44:51 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343592 - head/contrib/elftoolchain/readelf
Message-ID:  <201901302044.x0UKip73064621@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Wed Jan 30 20:44:51 2019
New Revision: 343592
URL: https://svnweb.freebsd.org/changeset/base/343592

Log:
  readelf: decode flag bits in DT_FLAGS/DT_FLAGS_1
  
  Decode d_val when the tag is DT_FLAGS or DT_FLAGS_1 based on the
  information at:
  
  https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-42444.html
  
  PR:		232983
  Submitted by:	Bora Ozarslan borako.ozarslan@gmail.com
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D18784

Modified:
  head/contrib/elftoolchain/readelf/readelf.c

Modified: head/contrib/elftoolchain/readelf/readelf.c
==============================================================================
--- head/contrib/elftoolchain/readelf/readelf.c	Wed Jan 30 20:23:16 2019	(r343591)
+++ head/contrib/elftoolchain/readelf/readelf.c	Wed Jan 30 20:44:51 2019	(r343592)
@@ -293,6 +293,8 @@ static void dump_dwarf_ranges_foreach(struct readelf *
 static void dump_dwarf_str(struct readelf *re);
 static void dump_eflags(struct readelf *re, uint64_t e_flags);
 static void dump_elf(struct readelf *re);
+static void dump_dt_flags_val(uint64_t d_val);
+static void dump_dt_flags_1_val(uint64_t d_val);
 static void dump_dyn_val(struct readelf *re, GElf_Dyn *dyn, uint32_t stab);
 static void dump_dynamic(struct readelf *re);
 static void dump_liblist(struct readelf *re);
@@ -2804,9 +2806,147 @@ dump_dyn_val(struct readelf *re, GElf_Dyn *dyn, uint32
 	case DT_GNU_PRELINKED:
 		printf(" %s\n", timestamp(dyn->d_un.d_val));
 		break;
+	case DT_FLAGS:
+		dump_dt_flags_val(dyn->d_un.d_val);
+		break;
+	case DT_FLAGS_1:
+		dump_dt_flags_1_val(dyn->d_un.d_val);
+		break;
 	default:
 		printf("\n");
 	}
+}
+
+static void
+dump_dt_flags_val(uint64_t d_val)
+{
+	if (d_val & 0x1) {
+		d_val ^= 0x1;
+		printf(" ORIGIN");
+	}
+	if (d_val & 0x2) {
+		d_val ^= 0x2;
+		printf(" SYMBOLIC");
+	}
+	if (d_val & 0x4) {
+		d_val ^= 0x4;
+		printf(" TEXTREL");
+	}
+	if (d_val & 0x8) {
+		d_val ^= 0x8;
+		printf(" BIND_NOW");
+	}
+	if (d_val & 0x10) {
+		d_val ^= 0x10;
+		printf(" STATIC_TLS");
+	}
+	if (d_val)
+		printf(" %lx", d_val);
+	printf("\n");
+}
+
+static void
+dump_dt_flags_1_val(uint64_t d_val)
+{
+	if (d_val & 0x1) {
+		d_val ^= 0x1;
+		printf(" NOW");
+	}
+	if (d_val & 0x2) {
+		d_val ^= 0x2;
+		printf(" GLOBAL");
+	}
+	if (d_val & 0x4) {
+		d_val ^= 0x4;
+		printf(" GROUP");
+	}
+	if (d_val & 0x8) {
+		d_val ^= 0x8;
+		printf(" NODELETE");
+	}
+	if (d_val & 0x10) {
+		d_val ^= 0x10;
+		printf(" LOADFLTR");
+	}
+	if (d_val & 0x20) {
+		d_val ^= 0x20;
+		printf(" INITFIRST");
+	}
+	if (d_val & 0x40) {
+		d_val ^= 0x40;
+		printf(" NOOPEN");
+	}
+	if (d_val & 0x80) {
+		d_val ^= 0x80;
+		printf(" ORIGIN");
+	}
+	if (d_val & 0x100) {
+		d_val ^= 0x100;
+		printf(" DIRECT");
+	}
+	if (d_val & 0x400) {
+		d_val ^= 0x400;
+		printf(" INTERPOSE");
+	}
+	if (d_val & 0x800) {
+		d_val ^= 0x800;
+		printf(" NODEFLIB");
+	}
+	if (d_val & 0x1000) {
+		d_val ^= 0x1000;
+		printf(" NODUMP");
+	}
+	if (d_val & 0x2000) {
+		d_val ^= 0x2000;
+		printf(" CONFALT");
+	}
+	if (d_val & 0x4000) {
+		d_val ^= 0x4000;
+		printf(" ENDFILTEE");
+	}
+	if (d_val & 0x8000) {
+		d_val ^= 0x8000;
+		printf(" DISPRELDNE");
+	}
+	if (d_val & 0x10000) {
+		d_val ^= 0x10000;
+		printf(" DISPRELPND");
+	}
+	if (d_val & 0x20000) {
+		d_val ^= 0x20000;
+		printf(" NODIRECT");
+	}
+	if (d_val & 0x40000) {
+		d_val ^= 0x40000;
+		printf(" IGNMULDEF");
+	}
+	if (d_val & 0x80000) {
+		d_val ^= 0x80000;
+		printf(" NOKSYMS");
+	}
+	if (d_val & 0x100000) {
+		d_val ^= 0x100000;
+		printf(" NOHDR");
+	}
+	if (d_val & 0x200000) {
+		d_val ^= 0x200000;
+		printf(" EDITED");
+	}
+	if (d_val & 0x400000) {
+		d_val ^= 0x400000;
+		printf(" NORELOC");
+	}
+	if (d_val & 0x800000) {
+		d_val ^= 0x800000;
+		printf(" SYMINTPOSE");
+	}
+	if (d_val & 0x1000000) {
+		d_val ^= 0x1000000;
+		printf(" GLOBAUDIT");
+	}
+	if (d_val)
+		printf(" %lx", d_val);
+	printf("\n");
 }
 
 static void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901302044.x0UKip73064621>