public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: aristovski@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  aristovski/validate-binary-before-use: Tests for validate symbol file using build-id.
Date: Mon, 15 Apr 2013 19:52:00 -0000	[thread overview]
Message-ID: <20130415195240.9356.qmail@sourceware.org> (raw)

The branch, aristovski/validate-binary-before-use has been updated
  discards  97a555f232b050adcd9d5b95822ac9b1b6d2755b (commit)
  discards  2bc7d2c57118746ed6a39d1b9abd340c326feaea (commit)
  discards  464bc79d0727d6586751b06e801fe8f7e22d6420 (commit)
  discards  0febecc57688434f71eed77c143c12e40e662310 (commit)
  discards  645577d52a6b417fc896ce6a3cc957cb1d2838e3 (commit)
  discards  6a5bda01e48d53498996569c29aca6b03d6cc4cb (commit)
  discards  519392ea6261576ec0a773476810c83c30342b6f (commit)
  discards  b06e48effcf38bd0320f2cf7aada3a397fc6d8e9 (commit)
  discards  3e1d712e728f05ab5b24a436b56bf560676b6c2c (commit)
  discards  9603e65c7b5db16b8de8f8b37143583b841ab8b6 (commit)
  discards  15a4db3d330067154d600a761536748340dc4992 (commit)
  discards  f9849003625ecaf3184ffef90b7b7ed72b9fec53 (commit)
  discards  d1950f293fe19ed8ea0c14a4ae572550acff6572 (commit)
  discards  d5bc0dfb8f8b60cfde5399c2e45c44ac99294bd9 (commit)
  discards  121df26f54673b3a458b54f8ab07349fe93a2fb4 (commit)
  discards  66064332170a9bee5920dcd3df581b01874c511b (commit)
  discards  008039efa87adf141a4c9910be0346e19d85f078 (commit)
  discards  aa1c4aede2eed583de3f4107da8572c0313fc979 (commit)
  discards  18b7ee9185d275e77961e73fada55f0c7ee1de55 (commit)
       via  f3af537c2c4595df30f2ef1d60706b51c6a9df11 (commit)
       via  a93c3646c09eb1125cb5070b8bad42dad5f8b07e (commit)
       via  659ff615c91a714fbe4f56068955c40bdf7234a8 (commit)
       via  1e324e602f9679cf00ac82306bdc0dd4de4611e0 (commit)
       via  6c805422d1704fee8bb033cb5b26a343ba7a60e9 (commit)
       via  504aa1b8c2b181a4d4deb6542961c804966d1775 (commit)
       via  34358983877ff06af9dba085317072896836351c (commit)
       via  37c064593ba6d72b03b3589fab66816a0b792999 (commit)
       via  20be147335c0ee6e21230c934ec790cf5380cfcb (commit)
      from  97a555f232b050adcd9d5b95822ac9b1b6d2755b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit f3af537c2c4595df30f2ef1d60706b51c6a9df11
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 16:06:26 2013 -0400

    Tests for validate symbol file using build-id.
    
    	* gdb.base/solib-mismatch-lib.c: New file.
    	* gdb.base/solib-mismatch-libmod.c: New file.
    	* gdb.base/solib-mismatch.c: New file.
    	* gdb.base/solib-mismatch.exp: New file.

commit a93c3646c09eb1125cb5070b8bad42dad5f8b07e
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 16:05:19 2013 -0400

    Validate symbol file using build-id.
    
    	* solib-darwin.c (_initialize_darwin_solib): Assign validate value.
    	* solib-dsbt.c (_initialize_dsbt_solib): Ditto.
    	* solib-frv.c (_initialize_frv_solib): Ditto.
    	* solib-ia64-hpux.c (ia64_hpux_target_so_ops): Ditto.
    	* solib-irix.c (_initialize_irix_solib): Ditto.
    	* solib-osf.c (_initialize_osf_solib): Ditto.
    	* solib-pa64.c (_initialize_pa64_solib): Ditto.
    	* solib-som.c (_initialize_som_solib): Ditto.
    	* solib-spu.c (set_spu_solib_ops): Ditto.
    	* solib-sunos.c (_initialize_sunos_solib): Ditto.
    	* solib-svr4.c (NOTE_GNU_BUILD_ID_NAME): New define.
    	(svr4_validate): New function.
    	(library_list_start_library): Parse 'build-id' attribute.
    	(svr4_library_attributes): Add 'build-id' attribute.
    	(_initialize_svr4_solib): Assign validate value.
    	* solib-target.c (solib.h): Include.
    	(_initialize_solib_target): Assign validate value.
    	* solib.c (solib_map_sections): Use ops->validate.
    	(free_so): Free build_id.
    	(solib_validate): New function.
    	* solib.h (solib_validate): New declaration.
    	* solist.h (so_list): New fields 'build_idsz' and 'build_id'.
    	(target_so_ops): New field 'validate'.

commit 659ff615c91a714fbe4f56068955c40bdf7234a8
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 11:56:57 2013 -0400

    gdbserver build-id attribute generator
    
        	* doc/gdb.texinfo (Library List Format for SVR4 Targets): Add
        	'build-id' in description, example, new attribute in dtd.
        	* features/library-list-svr4.dtd (library-list-svr4): New
        	'build-id' attribute.
        	* linux-low.c (linux-maps.h, search.h): Include.
    	(ElfXX_Ehdr, ElfXX_Phdr, ElfXX_Nhdr): New.
    	(ELFXX_FLD, ELFXX_SIZEOF, ELFXX_ROUNDUP, BUILD_ID_INVALID): New.
        	(find_phdr): New.
        	(get_dynamic): Use find_pdhr to traverse program headers.
        	(struct mapping_entry): New structure.
        	(mapping_entry_s): New typedef, new vector type def.
        	(free_mapping_entry, compare_mapping_entry,
        	 compare_mapping_entry_range, compare_mapping_entry_inode): New.
        	(struct find_memory_region_callback_data): New.
        	(find_memory_region_callback): New fwd. declaration.
        	(read_build_id, find_memory_region_callback, get_hex_build_id): New.
        	(linux_qxfer_libraries_svr4): Add optional build-id attribute
        	to reply XML document.

commit 1e324e602f9679cf00ac82306bdc0dd4de4611e0
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 09:54:36 2013 -0400

    Move linux_find_memory_regions_full & co.
    
    	* common/common-target.c (gdb_assert.h, gdb_string.h): Include.
    	(read_alloc, read_stralloc): Move definitions from target.c.
    	* common/common-target.h (read_alloc_pread_ftype): New typedef.
    	(read_alloc): New declaration.
    	(read_stralloc_func_ftype): New typedef.
    	(read_stralloc): New declaration.
    	* common/linux-maps.c (fcntl.h, unistd.h, target.h, gdb_assert.h,
    	ctype.h, string.h, common-target.h): Include.
    	(read_mapping): Move from linux-tdep.c.
    	(linux_find_memory_read_stralloc_1_pread): New function.
    	(linux_find_memory_read_stralloc_1): New function.
    	(linux_find_memory_read_stralloc): New function.
    	* common/linux-maps.h (read_mapping): New declaration.
    	(linux_find_memory_region_ftype): Moved typedef from linux-tdep.c.
    	(linux_find_memory_regions_full): New declaration.
    	* linux-tdep.c (linux-maps.h): Include.
    	(read_mapping): Moved to common/linux-maps.c.
    	(linux_find_memory_region_ftype): Moved typedef to common/linux-maps.h.
    	(linux_find_memory_regions_full): Moved definition to
    	common/linux-maps.c.
    	* target.c (common-target.h): Include.
    	(read_alloc_pread_ftype): Moved typedef to common/common-target.h.
    	(read_alloc, read_stralloc): Moved definitions to
    	common/common-target.c.

commit 6c805422d1704fee8bb033cb5b26a343ba7a60e9
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 09:49:36 2013 -0400

    Prepare linux_find_memory_regions_full & co. for move
    
    	* linux-tdep.c (linux_find_memory_region_ftype): Comment.
    	(linux_find_memory_regions_full): Change signature and prepare
    	for moving to linux-maps.
    	(linux_find_memory_regions_data): Rename field 'obfd' to 'data'.
    	(linux_find_memory_regions_thunk): New.
    	(linux_find_memory_regions_thunk): Use 'data' field instead of 'obfd'.
    	(linux_find_memory_regions_gdb): New.
    	(linux_find_memory_regions): Rename argument 'obfd' to 'func_data'.
    	(linux_make_mappings_corefile_notes): Use
    	linux_find_memory_regions_gdb.
    	* target.c (read_alloc_pread_ftype): New typedef.
    	(target_fileio_read_alloc_1_pread): New function.
    	(read_alloc): Refactor from target_fileio_read_alloc_1.
    	(read_stralloc_func_ftype): New typedef.
    	(target_fileio_read_alloc_1): New implementation. Use read_alloc.
    	(read_stralloc): Refactored from target_fileio_read_stralloc.
    	(target_fileio_read_stralloc): New implementation, use read_stralloc.

commit 504aa1b8c2b181a4d4deb6542961c804966d1775
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 09:40:24 2013 -0400

    Create empty common/linux-maps.[ch] and common/common-target.[ch]
    
    	* Makefile.in (HFILES_NO_SRCDIR); Add common/linux-maps.h,
    	common/common-target.h.
    	(COMMON_OBS): Add common-target.o.
    	(linux-maps.o, common-target.o): New.
    	* common/common-target.c: New file.
    	* common/common-target.h: New file.
    	* common/linux-maps.c: New file.
    	* common/linux-maps.h: New file.
    	* config/i386/linux.mh (NATDEPFILES): Add linux-maps.o.
    	* config/i386/linux64.mh (NATDEPFILES): Ditto.
    	* gdbserver/Makefile.in (OBS): Add common-taret.o.
    	(linux-maps.o, common-target.o): New.
    	* gdbserver/configure.srv (srv_tgtobj): Add linux-maps.o.

commit 34358983877ff06af9dba085317072896836351c
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 09:39:05 2013 -0400

    Merge multiple hex conversions
    
    	* common/common-utils.c (fromhex): Make externally linkable.
    	Change error message.
    	(tohex): Make externally linkable.
    	* common/common-utils.h (fromhex, tohex): New declaration.
    	* gdbserver/gdbreplay.c (tohex): Rename to 'fromhex'.
    	(logchar): Use fromhex.
    	* gdbserver/remote-utils.c (fromhex, unhexify): Remove.
    	(tohex, hexify): Remove.
    	(look_up_one_symbol, monitor_output): Use bin2hex instead of hexify.
    	* gdbserver/server.c (handle_query): Use bin2hex instead of hexify.
    	(handle_v_run): Ditto.
    	* gdbserver/server.h (unhexify, hexify): Remove declarations.
    	* gdbserver/tracepoint.c (cmd_qtdpsrc, cmd_qtdv): Use hex2bin
    	instead of unhexify.
    	(cmd_qtstatus): Use bin2hex instead of hexify.
    	(cmd_qtnotes): Use hex2bin instead of unhexify.
    	* monitor.c (fromhex): Remove definition.
    	* remote.c (tohex, fromhex): Remove fwd declarations, remove
    	definitions.

commit 37c064593ba6d72b03b3589fab66816a0b792999
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Mar 27 09:39:05 2013 -0400

    Move utility functions to common/
    
    	* cli/cli-utils.c (skip_spaces, skip_spaces_const): Move defs to
    	common/common-utils.c.
    	* cli/cli-utils.h (skip_spaces, skip_spaces_const): Move decls to
    	common/common-utils.h.
    	* common/common-utils.c (ctype.h): Include.
    	(HIGH_BYTE_POSN, is_digit_in_base, digit_to_int, strtoulst): Move
    	from utils.c.
    	(fromhex): Copy from remote.c.
    	(hex2bin): Move from remote.c.
    	(tohex): Copy from remote.c.
    	(bin2hex): Move from remote.c.
    	(skip_spaces, skip_spaces_const): Move from cli/cli-utils.c.
    	* common/common-utils.h (TARGET_CHAR_BIT, HOST_CHAR_BIT): Moved
    	from defs.h.
    	(strtoulst): Move decl from utils.h.
    	(hex2bin, bin2hex): Move decls from remote.h.
    	(skip_spaces, skip_spaces_const): Move decls from cli/cli-utils.h.
    	* defs.h (TARGET_CHAR_BIT, HOST_CHAR_BIT): Move to
    	common/common-utils.h
    	* remote.c (hex2bin, bin2hex): Moved defs to common/common-utils.c.
    	* remote.h (hex2bin, bin2hex): Moved decls to common/common-utils.h.
    	* utils.c (HIGH_BYTE_POSN, is_digit_in_base, digit_to_int,
    	strtoulst): Move to common/common-utils.c.
    	* utils.h (strtoulst): Moved decl to common/common-utils.h.

commit 20be147335c0ee6e21230c934ec790cf5380cfcb
Author: Aleksandar Ristovski <ARistovski@qnx.com>
Date:   Wed Apr 10 14:01:34 2013 -0400

    Add README.archer

-----------------------------------------------------------------------

Summary of changes:
 gdb/common/common-target.c                |    1 -
 gdb/common/common-target.h                |    1 -
 gdb/common/linux-maps.c                   |   36 +++++++++-----
 gdb/gdbserver/linux-low.c                 |   72 ++++++++++++++++-------------
 gdb/solib-svr4.c                          |   25 ++++++----
 gdb/solib.c                               |    6 --
 gdb/target.c                              |   10 ++++
 gdb/testsuite/gdb.base/solib-mismatch.c   |   42 ++++++-----------
 gdb/testsuite/gdb.base/solib-mismatch.exp |   69 +++++++++++++++------------
 9 files changed, 140 insertions(+), 122 deletions(-)

First 500 lines of diff:
diff --git a/gdb/common/common-target.c b/gdb/common/common-target.c
index d0b3138..907f95c 100644
--- a/gdb/common/common-target.c
+++ b/gdb/common/common-target.c
@@ -113,4 +113,3 @@ read_stralloc (const char *filename, read_stralloc_func_ftype *func)
 
   return bufstr;
 }
-
diff --git a/gdb/common/common-target.h b/gdb/common/common-target.h
index 21f21ef..b252c00 100644
--- a/gdb/common/common-target.h
+++ b/gdb/common/common-target.h
@@ -32,4 +32,3 @@ extern char *read_stralloc (const char *filename,
 			    read_stralloc_func_ftype *func);
 
 #endif /* COMMON_COMMON_TARGET_H */
-
diff --git a/gdb/common/linux-maps.c b/gdb/common/linux-maps.c
index 3fcd316..6432b8f 100644
--- a/gdb/common/linux-maps.c
+++ b/gdb/common/linux-maps.c
@@ -126,16 +126,16 @@ int
 linux_find_memory_regions_full (pid_t pid, linux_find_memory_region_ftype *func,
 				void *func_data, void **memory_to_free_ptr)
 {
-  char filename[100];
+  char mapsfilename[100];
   char *data;
 
-  xsnprintf (filename, sizeof filename, "/proc/%d/smaps", (int) pid);
-  data = linux_find_memory_read_stralloc (filename);
+  xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/smaps", (int) pid);
+  data = linux_find_memory_read_stralloc (mapsfilename);
   if (data == NULL)
     {
       /* Older Linux kernels did not support /proc/PID/smaps.  */
-      xsnprintf (filename, sizeof filename, "/proc/%d/maps", (int) pid);
-      data = linux_find_memory_read_stralloc (filename);
+      xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/maps", (int) pid);
+      data = linux_find_memory_read_stralloc (mapsfilename);
     }
   if (data)
     {
@@ -171,20 +171,30 @@ linux_find_memory_regions_full (pid_t pid, linux_find_memory_region_ftype *func,
 	       line = strtok (NULL, "\n"))
 	    {
 	      char keyword[64 + 1];
-	      unsigned long number;
 
-	      if (sscanf (line, "%64s%lu kB\n", keyword, &number) != 2)
+	      if (sscanf (line, "%64s", keyword) != 1)
 		{
-		  warning (_("Error parsing {s,}maps file '%s'"), filename);
+		  warning (_("Error parsing {s,}maps file '%s'"), mapsfilename);
 		  break;
 		}
 	      if (strcmp (keyword, "Anonymous:") == 0)
 		has_anonymous = 1;
-	      if (number != 0 && (strcmp (keyword, "Shared_Dirty:") == 0
-				  || strcmp (keyword, "Private_Dirty:") == 0
-				  || strcmp (keyword, "Swap:") == 0
-				  || strcmp (keyword, "Anonymous:") == 0))
-		modified = 1;
+	      if (strcmp (keyword, "Shared_Dirty:") == 0
+		  || strcmp (keyword, "Private_Dirty:") == 0
+		  || strcmp (keyword, "Swap:") == 0
+		  || strcmp (keyword, "Anonymous:") == 0)
+		{
+		  unsigned long number;
+
+		  if (sscanf (line, "%*s%lu", &number) != 1)
+		    {
+		      warning (_("Error parsing {s,}maps file '%s' number"),
+			       mapsfilename);
+		      break;
+		    }
+		  if (number != 0)
+		    modified = 1;
+		}
 	    }
 
 	  /* Older Linux kernels did not support the "Anonymous:" counter.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index d819b21..8d8ba17 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -138,13 +138,14 @@ typedef union ElfXX_Nhdr
   Elf64_Nhdr _64;
 } ElfXX_Nhdr;
 
-#define ELFXX_FLD(hdr, fld) ((is_elf64) ? (hdr)._64.fld : (hdr)._32.fld)
-#define ELFXX_SIZEOF(hdr) ((is_elf64) ? sizeof ((hdr)._64) \
-				      : sizeof ((hdr)._32))
-#define ELFXX_ROUNDUP(what) ((is_elf64) ? (((what) + sizeof (Elf64_Word) - 1) \
-					   & ~(sizeof (Elf64_Word) - 1))      \
-					: (((what) + sizeof (Elf32_Word) - 1) \
-					   & ~(sizeof (Elf32_Word) - 1)))
+#define ELFXX_FLD(elf64, hdr, fld) ((elf64) ? (hdr)._64.fld : (hdr)._32.fld)
+#define ELFXX_SIZEOF(elf64, hdr) ((elf64) ? sizeof ((hdr)._64) \
+					  : sizeof ((hdr)._32))
+/* Round up to next 4 byte boundary.  */
+#define ELFXX_ROUNDUP_4(elf64, what) ((elf64) ? (((what) + 3)		\
+						 & ~((Elf64_Word)3U))	\
+					      : (((what) + 3)		\
+						 & ~((Elf32_Word) 3U)))
 #define BUILD_ID_INVALID "?"
 
 /* ``all_threads'' is keyed by the LWP ID, which we use as the GDB protocol
@@ -5470,7 +5471,7 @@ find_phdr (const int is_elf64, const void *const phdr_begin,
 	   const void *const phdr_end, const ULONGEST p_type)
 {
 #define PHDR_NEXT(hdrp) ((const void *) ((const gdb_byte *) (hdrp) + \
-			 ELFXX_SIZEOF (*hdrp)))
+			 ELFXX_SIZEOF (is_elf64, *hdrp)))
 
   const ElfXX_Phdr *phdr = phdr_begin;
 
@@ -5479,7 +5480,7 @@ find_phdr (const int is_elf64, const void *const phdr_begin,
 
   while (PHDR_NEXT (phdr) <= phdr_end)
     {
-      if (ELFXX_FLD (*phdr, p_type) == p_type)
+      if (ELFXX_FLD (is_elf64, *phdr, p_type) == p_type)
 	return phdr;
       phdr = PHDR_NEXT (phdr);
     }
@@ -5776,22 +5777,24 @@ read_build_id (struct find_memory_region_callback_data *const p,
   ElfXX_Ehdr ehdr;
 
   if (linux_read_memory (load_addr, (unsigned char *) &ehdr,
-			 ELFXX_SIZEOF (ehdr)) == 0
-      && ELFXX_FLD (ehdr, e_ident[EI_MAG0]) == ELFMAG0
-      && ELFXX_FLD (ehdr, e_ident[EI_MAG1]) == ELFMAG1
-      && ELFXX_FLD (ehdr, e_ident[EI_MAG2]) == ELFMAG2
-      && ELFXX_FLD (ehdr, e_ident[EI_MAG3]) == ELFMAG3)
+			 ELFXX_SIZEOF (is_elf64, ehdr)) == 0
+      && ELFXX_FLD (is_elf64, ehdr, e_ident[EI_MAG0]) == ELFMAG0
+      && ELFXX_FLD (is_elf64, ehdr, e_ident[EI_MAG1]) == ELFMAG1
+      && ELFXX_FLD (is_elf64, ehdr, e_ident[EI_MAG2]) == ELFMAG2
+      && ELFXX_FLD (is_elf64, ehdr, e_ident[EI_MAG3]) == ELFMAG3)
     {
       const ElfXX_Phdr *phdr;
       void *phdr_buf;
-      const unsigned e_phentsize = ELFXX_FLD (ehdr, e_phentsize);
+      const unsigned e_phentsize = ELFXX_FLD (is_elf64, ehdr, e_phentsize);
 
-      gdb_assert (ELFXX_FLD (ehdr, e_phnum) < 100);  /* Basic sanity check.  */
-      gdb_assert (e_phentsize == ELFXX_SIZEOF (*phdr));
-      phdr_buf = alloca (ELFXX_FLD (ehdr, e_phnum) * e_phentsize);
+      gdb_assert (ELFXX_FLD (is_elf64, ehdr, e_phnum) < 100);  /* Basic sanity check.  */
+      gdb_assert (e_phentsize == ELFXX_SIZEOF (is_elf64, *phdr));
+      phdr_buf = alloca (ELFXX_FLD (is_elf64, ehdr, e_phnum) * e_phentsize);
 
-      if (linux_read_memory (load_addr + ELFXX_FLD (ehdr, e_phoff), phdr_buf,
-			     ELFXX_FLD (ehdr, e_phnum) * e_phentsize) != 0)
+      if (linux_read_memory (load_addr + ELFXX_FLD (is_elf64, ehdr, e_phoff),
+			     phdr_buf,
+			     ELFXX_FLD (is_elf64, ehdr, e_phnum) * e_phentsize)
+	  != 0)
 	{
 	  warning ("Could not read program header.");
 	  return;
@@ -5806,15 +5809,16 @@ read_build_id (struct find_memory_region_callback_data *const p,
 	  const ElfXX_Nhdr *nhdr;
 
 	  phdr = find_phdr (p->is_elf64, phdr, (gdb_byte *) phdr_buf
-			    + ELFXX_FLD (ehdr, e_phnum) * e_phentsize,
+			    + ELFXX_FLD (is_elf64, ehdr, e_phnum) * e_phentsize,
 			    PT_NOTE);
 	  if (phdr == NULL)
 	    break;
-	  pt_note = xmalloc (ELFXX_FLD (*phdr, p_memsz));
-	  pt_end = (gdb_byte*) pt_note + ELFXX_FLD (*phdr, p_memsz);
+	  pt_note = xmalloc (ELFXX_FLD (is_elf64, *phdr, p_memsz));
+	  pt_end = (gdb_byte*) pt_note + ELFXX_FLD (is_elf64, *phdr, p_memsz);
 
-	  if (linux_read_memory (ELFXX_FLD (*phdr, p_vaddr) + l_addr, pt_note,
-				 ELFXX_FLD (*phdr, p_memsz)) != 0)
+	  if (linux_read_memory (ELFXX_FLD (is_elf64, *phdr, p_vaddr) + l_addr,
+				 pt_note, ELFXX_FLD (is_elf64, *phdr, p_memsz))
+	      != 0)
 	    {
 	      xfree (pt_note);
 	      warning ("Could not read note.");
@@ -5825,10 +5829,13 @@ read_build_id (struct find_memory_region_callback_data *const p,
 	  while ((void *) nhdr < (void *) pt_end)
 	    {
 	      const size_t namesz
-		= ELFXX_ROUNDUP (ELFXX_FLD (*nhdr, n_namesz));
+		= ELFXX_ROUNDUP_4 (is_elf64, ELFXX_FLD (is_elf64, *nhdr,
+							n_namesz));
 	      const size_t descsz
-		= ELFXX_ROUNDUP (ELFXX_FLD (*nhdr, n_descsz));
-	      const size_t note_sz = ELFXX_SIZEOF (*nhdr) + namesz + descsz;
+		= ELFXX_ROUNDUP_4 (is_elf64, ELFXX_FLD (is_elf64, *nhdr,
+							n_descsz));
+	      const size_t note_sz = ELFXX_SIZEOF (is_elf64, *nhdr) + namesz
+				     + descsz;
 
 	      if (((gdb_byte *) nhdr + note_sz) > pt_end || note_sz == 0
 		  || descsz == 0)
@@ -5836,16 +5843,17 @@ read_build_id (struct find_memory_region_callback_data *const p,
 		  warning ("Malformed PT_NOTE\n");
 		  break;
 		}
-	      if (ELFXX_FLD (*nhdr, n_type) == NT_GNU_BUILD_ID
-		  && ELFXX_FLD (*nhdr, n_namesz) == 4)
+	      if (ELFXX_FLD (is_elf64, *nhdr, n_type) == NT_GNU_BUILD_ID
+		  && ELFXX_FLD (is_elf64, *nhdr, n_namesz) == 4)
 		{
 		  const char gnu[4] = "GNU\0";
 		  const char *const pname
-		    = (char *) nhdr + ELFXX_SIZEOF (*nhdr);
+		    = (char *) nhdr + ELFXX_SIZEOF (is_elf64, *nhdr);
 
 		  if (memcmp (pname, gnu, 4) == 0)
 		    {
-		      const size_t n_descsz = ELFXX_FLD (*nhdr, n_descsz);
+		      const size_t n_descsz = ELFXX_FLD (is_elf64, *nhdr,
+							 n_descsz);
 
 		      bil->hex_build_id = xmalloc (n_descsz * 2 + 1);
 		      bin2hex ((gdb_byte*) pname + namesz, bil->hex_build_id,
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 54a7e6f..d576245 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -881,6 +881,7 @@ svr4_validate (const struct so_list *const so)
 {
   gdb_byte *build_id;
   size_t build_idsz;
+  size_t abfd_build_idsz;
 
   gdb_assert (so != NULL);
 
@@ -894,6 +895,7 @@ svr4_validate (const struct so_list *const so)
 
   build_id = so->build_id;
   build_idsz = so->build_idsz;
+  abfd_build_idsz = elf_tdata (so->abfd)->build_id->size;
 
   if (build_id == NULL)
     {
@@ -930,7 +932,7 @@ svr4_validate (const struct so_list *const so)
 					    sizeof (note->descsz),
 					    byte_order);
 
-	      if (build_idsz == elf_tdata (so->abfd)->build_id->size)
+	      if (build_idsz == abfd_build_idsz)
 		{
 		  const char gnu[4] = "GNU\0";
 
@@ -945,9 +947,8 @@ svr4_validate (const struct so_list *const so)
 		      /* Rounded to next sizeof (ElfXX_Word).  */
 		      namesz = ((namesz + (sizeof (note->namesz) - 1))
 				& ~((ULONGEST) (sizeof (note->namesz) - 1)));
-		      build_id_offs = (sizeof (note->namesz)
-				       + sizeof (note->descsz)
-				       + sizeof (note->type) + namesz);
+		      build_id_offs = (offsetof (Elf_External_Note, name)
+				       + namesz);
 		      build_id = xmalloc (build_idsz);
 		      memcpy (build_id, note_raw + build_id_offs, build_idsz);
 		    }
@@ -971,9 +972,9 @@ svr4_validate (const struct so_list *const so)
   if (build_id != NULL)
     {
       const int match
-	= elf_tdata (so->abfd)->build_id->size == build_idsz
-	  && memcmp (build_id, elf_tdata (so->abfd)->build_id->data,
-		     elf_tdata (so->abfd)->build_id->size) == 0;
+	= (abfd_build_idsz == build_idsz
+	   && memcmp (build_id, elf_tdata (so->abfd)->build_id->data,
+		      build_idsz) == 0);
 
       if (build_id != so->build_id)
 	xfree (build_id);
@@ -1130,12 +1131,14 @@ library_list_start_library (struct gdb_xml_parser *parser,
     {
       const size_t hex_build_id_len = strlen (hex_build_id);
 
-      if (hex_build_id_len > 0)
+      if (hex_build_id_len > 0 && (hex_build_id_len & 1U) == 0)
 	{
-	  new_elem->build_id = xmalloc (hex_build_id_len / 2);
+	  const size_t build_idsz = hex_build_id_len / 2;
+
+	  new_elem->build_id = xmalloc (build_idsz);
 	  new_elem->build_idsz = hex2bin (hex_build_id, new_elem->build_id,
-					  hex_build_id_len);
-	  if (new_elem->build_idsz != (hex_build_id_len / 2))
+					  build_idsz);
+	  if (new_elem->build_idsz != build_idsz)
 	    {
 	      xfree (new_elem->build_id);
 	      new_elem->build_id = NULL;
diff --git a/gdb/solib.c b/gdb/solib.c
index 20c709e..9950338 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -465,12 +465,6 @@ solib_map_sections (struct so_list *so)
   /* Leave bfd open, core_xfer_memory and "info files" need it.  */
   so->abfd = abfd;
 
-  /* copy full path name into so_name, so that later symbol_file_add
-     can find it.  */
-  if (strlen (bfd_get_filename (abfd)) >= SO_NAME_MAX_PATH_SIZE)
-    error (_("Shared library file name is too long."));
-  strcpy (so->so_name, bfd_get_filename (abfd));
-
   gdb_assert (ops->validate != NULL);
 
   if (!ops->validate (so))
diff --git a/gdb/target.c b/gdb/target.c
index 1a7e091..db06389 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3477,6 +3477,11 @@ target_fileio_close_cleanup (void *opaque)
   target_fileio_close (fd, &target_errno);
 }
 
+typedef int (read_alloc_pread_ftype) (int handle, gdb_byte *read_buf, int len,
+				      ULONGEST offset, int *target_errno);
+
+static read_alloc_pread_ftype target_fileio_read_alloc_1_pread;
+
 /* Helper for target_fileio_read_alloc_1 to make it interruptible.  */
 
 static int
@@ -3488,6 +3493,11 @@ target_fileio_read_alloc_1_pread (int handle, gdb_byte *read_buf, int len,
   return target_fileio_pread (handle, read_buf, len, offset, target_errno);
 }
 
+typedef LONGEST (read_stralloc_func_ftype) (const char *filename,
+					    gdb_byte **buf_p, int padding);
+
+static read_stralloc_func_ftype target_fileio_read_alloc_1;
+
 /* Read target file FILENAME.  Store the result in *BUF_P and
    return the size of the transferred data.  PADDING additional bytes are
    available in *BUF_P.  This is a helper function for
diff --git a/gdb/testsuite/gdb.base/solib-mismatch.c b/gdb/testsuite/gdb.base/solib-mismatch.c
index 8a7f58f..7a5d960 100644
--- a/gdb/testsuite/gdb.base/solib-mismatch.c
+++ b/gdb/testsuite/gdb.base/solib-mismatch.c
@@ -24,45 +24,33 @@
 
 /* The following defines must correspond to solib-mismatch.exp */
 
-#define DIRNAME "solib-mismatch_wd"
-#define LIB "./solib-mismatch.so"
-
-int main(int argc, char *argv[])
+/* DIRNAME must be defined at compile time.  */
+#ifndef DIRNAME
+#error DIRNAME not defined
+#endif
+#ifndef LIB
+#error LIB not defined
+#endif
+
+int main (int argc, char *argv[])
 {
   void *h;
-  int (*foo)(void);
-  char buff[1024];
-  char *p;
-
-  p = strstr (argv[0], DIRNAME);
-
-  if (p == NULL)
-    {
-      printf ("ERROR - %s could not be found in argv[0]\n", DIRNAME);
-      return 1;
-    }
-
-  p += strlen (DIRNAME);
-
-  memcpy (buff, argv[0], p - argv[0]);
+  int (*foo) (void);
 
-  buff[p - argv[0]] = '\0';
-
-  if (chdir (buff) != 0)
+  if (chdir (DIRNAME) != 0)
     {
-      printf ("ERROR - Could not cd to %s\n", buff);
+      printf ("ERROR - Could not cd to %s\n", DIRNAME);
       return 1;
     }
 
-  h = dlopen(LIB, RTLD_NOW);
+  h = dlopen (LIB, RTLD_NOW);
 
   if (h == NULL)
     {
       printf ("ERROR - could not open lib %s\n", LIB);
       return 1;
     }
-  foo = dlsym(h, "foo"); /* set breakpoint 1 here */
-  dlclose(h);
+  foo = dlsym (h, "foo"); /* set breakpoint 1 here */
+  dlclose (h);
   return 0;
 }
-
diff --git a/gdb/testsuite/gdb.base/solib-mismatch.exp b/gdb/testsuite/gdb.base/solib-mismatch.exp
index a242618..4504bc3 100644
--- a/gdb/testsuite/gdb.base/solib-mismatch.exp
+++ b/gdb/testsuite/gdb.base/solib-mismatch.exp
@@ -23,6 +23,7 @@ set executable $testfile
 
 if { [get_compiler_info] } {
   untested "get_compiler_info failed."
+  return -1
 }
 
 # First version of the object, to be loaded by ld.
@@ -34,7 +35,7 @@ set srclibfilerun ${testfile}-lib.c
 set srclibfilegdb ${testfile}-libmod.c
 
 # So file name:
-set binlibfilebase ${testfile}.so
+set binlibfilebase lib${testfile}.so
 
 # Setup run directory (where program is run from)
 #   It contains executable and '-lib' version of the library.
@@ -45,27 +46,29 @@ set binlibfilerun ${binlibfiledirrun}/${binlibfilebase}
 set binlibfiledirgdb [standard_output_file ""]
 set binlibfilegdb ${binlibfiledirgdb}/${binlibfilebase}
 
-# Executeable
+# Executable
 set srcfile ${testfile}.c
 set executable ${testfile}
-set objfile [standard_output_file ${executable}.o]
-set binfile [standard_output_file ${executable}]
 
+file delete -force -- "${binlibfiledirrun}"
 file mkdir "${binlibfiledirrun}"
 
 set exec_opts {}
 
 if { ![istarget "*-*-nto-*"] } {
-  set exec_opts [list debug shlib_load]
+  lappend exec_opts "shlib_load"
 }
 
-if { [prepare_for_testing $testfile.exp $executable $srcfile $exec_opts] != 0 } {
+lappend exec_opts "additional_flags=-DDIRNAME\=\"${binlibfiledirrun}\" -DLIB\=\"./${binlibfilebase}\""
+lappend exec_opts "debug"
+
+if { [build_executable $testfile.exp $executable $srcfile $exec_opts] != 0 } {
   return -1
 }
 
-if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfilerun}" "${binlibfilerun}" [list debug ldflags=-Wl,-soname,${binlibfilebase},--build-id]] != ""
+if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfilerun}" "${binlibfilerun}" [list debug ldflags=-Wl,--build-id]] != ""
      || [gdb_gnu_strip_debug "${binlibfilerun}"]
-     || [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfilegdb}" "${binlibfilegdb}" [list debug ldflags=-Wl,-soname,${binlibfilebase},--build-id]] != "" } {
+     || [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfilegdb}" "${binlibfilegdb}" [list debug ldflags=-Wl,--build-id]] != "" } {
   untested "gdb_compile_shlib failed."
   return -1
 }
@@ -82,21 +85,21 @@ proc solib_matching_test { solibfile symsloaded msg } {
 
   clean_restart ${binlibfiledirrun}/${executable}
 
-  send_gdb "set solib-search-path \"${binlibfiledirgdb}\"\n"
-  send_gdb "cd ${binlibfiledirgdb}\n"
-# Do not auto load shared libraries, the test needs to have control
-# over when the relevant output gets printed
-  send_gdb "set auto-solib-add off\n"
+  gdb_test_no_output "set solib-search-path \"${binlibfiledirgdb}\"" ""
+  if { [gdb_test "cd ${binlibfiledirgdb}" "" ""] != 0 } {
+    untested "cd ${binlibfiledirgdb}"
+    return -1
+  }
 
-  set bp_location [gdb_get_line_number "set breakpoint 1 here"]
+  # Do not auto load shared libraries, the test needs to have control
+  # over when the relevant output gets printed.
+  gdb_test_no_output "set auto-solib-add off" ""
 
-  gdb_breakpoint ${srcfile}:${bp_location} temporary no-message
+  if ![runto "${srcfile}:[gdb_get_line_number "set breakpoint 1 here"]"] {
+    return -1
+  }
 
-  gdb_run_cmd { ${binlibfiledirrun} }
-  gdb_test "" "set breakpoint 1 here.*" ""
-
-  send_gdb "sharedlibrary\n"
-  gdb_test "" "" ""
+  gdb_test "sharedlibrary" "" ""
 
   set nocrlf "\[^\r\n\]*"
   set expected_header "From${nocrlf}To${nocrlf}Syms${nocrlf}Read${nocrlf}Shared${nocrlf}"
@@ -105,6 +108,7 @@ proc solib_matching_test { solibfile symsloaded msg } {


hooks/post-receive
--
Repository for Project Archer.


             reply	other threads:[~2013-04-15 19:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15 19:52 aristovski [this message]
2013-04-16 13:19 aristovski

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=20130415195240.9356.qmail@sourceware.org \
    --to=aristovski@sourceware.org \
    --cc=archer-commits@sourceware.org \
    /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).