rpms/oprofile/devel oprofile-0.8.2-ppc64dot.patch, NONE, 1.1 oprofile.spec, 1.26, 1.27

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Tue Apr 5 14:01:06 UTC 2005


Update of /cvs/dist/rpms/oprofile/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv1867

Modified Files:
	oprofile.spec 
Added Files:
	oprofile-0.8.2-ppc64dot.patch 
Log Message:
Back port of patch for ppc64 dotted symbol support.



oprofile-0.8.2-ppc64dot.patch:
 configure.in         |   29 +++++++++++++++++
 libutil++/op_bfd.cpp |   86 +++++++++++++++++++++++++++++++++++++++++++++++++--
 libutil++/op_bfd.h   |   12 +++++++
 3 files changed, 125 insertions(+), 2 deletions(-)

--- NEW FILE oprofile-0.8.2-ppc64dot.patch ---
--- oprofile-0.8.2/configure.in.orig	2005-04-05 09:36:37.000000000 -0400
+++ oprofile-0.8.2/configure.in	2005-04-05 09:37:43.000000000 -0400
@@ -188,6 +188,35 @@
 OP_DOCDIR=`eval echo "${my_op_prefix}/share/doc/$PACKAGE/"`
 AC_SUBST(OP_DOCDIR)
 
+# Determine if bfd_get_synthetic_symtab macro is available
+OS="`uname`"
+if test "$OS" = "Linux"; then
+	AC_MSG_CHECKING([whether bfd_get_synthetic_symtab() exists in BFD library])
+	rm -f test-for-synth
+	AC_LANG(C)
+	AC_LANG_CONFTEST(
+		[AC_LANG_PROGRAM([[#include <bfd.h>]],
+			[[asymbol * synthsyms;	bfd * ibfd = 0; 
+			long synth_count = bfd_get_synthetic_symtab(ibfd, 0, 0, 0, 0, &synthsyms);
+			extern const bfd_target bfd_elf64_powerpc_vec;
+			extern const bfd_target bfd_elf64_powerpcle_vec;
+			char * ppc_name = bfd_elf64_powerpc_vec.name;
+			char * ppcle_name = bfd_elf64_powerpcle_vec.name;]])
+		])
+	gcc conftest.$ac_ext -lbfd -liberty -o  test-for-synth > /dev/null 2>&1
+	if test -f test-for-synth; then
+		echo "yes"
+		SYNTHESIZE_SYMBOLS='1'
+	else
+		echo "no"
+		SYNTHESIZE_SYMBOLS='0'
+	fi
+	AC_DEFINE_UNQUOTED(SYNTHESIZE_SYMBOLS, $SYNTHESIZE_SYMBOLS, [Synthesize special symbols when needed])
+	rm -f test-for-synth*
+
+fi
+
+
 AC_OUTPUT(Makefile \
 	m4/Makefile \
 	libutil/Makefile \
--- oprofile-0.8.2/libutil++/op_bfd.cpp.orig	2005-01-24 10:51:42.000000000 -0500
+++ oprofile-0.8.2/libutil++/op_bfd.cpp	2005-04-05 09:35:05.000000000 -0400
@@ -11,6 +11,7 @@
 
 #include "op_file.h"
 #include "op_config.h"
+#include "config.h"
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -284,7 +285,8 @@
 	ibfd(0),
 	dbfd(0),
 	text_offset(0),
-	debug_info(false)
+	debug_info(false),
+	prev_total_symcount(0)
 {
 	string image_path = archive_path + filename;
 	int fd;
@@ -486,12 +488,92 @@
 
 } // namespace anon
 
+
+#if SYNTHESIZE_SYMBOLS
+
+uint op_bfd::process_symtab(bfd * ibfd, size_t start) 
+{
+	extern const bfd_target bfd_elf64_powerpc_vec;
+	extern const bfd_target bfd_elf64_powerpcle_vec;
+	bool is_elf64_powerpc_target = (ibfd->xvec == &bfd_elf64_powerpc_vec)
+		|| (ibfd->xvec == &bfd_elf64_powerpcle_vec);
+
+	if (!is_elf64_powerpc_target)
+		return bfd_canonicalize_symtab(ibfd, bfd_syms.get() + start);
+
+	void * minisyms;
+	uint minisym_count = 0;
+	uint size;
+
+	minisym_count = bfd_read_minisymbols(ibfd, 0, &minisyms, &size);
+	if (minisym_count < 1)
+		return 0;
+	
+	asymbol ** mysyms;
+	asymbol *synthsyms;
+	long synth_count;
+
+	mysyms = (asymbol **)minisyms;
+	synth_count = bfd_get_synthetic_symtab(ibfd, minisym_count, mysyms,
+	                                       0, NULL, &synthsyms);
+
+	/* synth_count will be zero for binaries that already have
+	 * dot symbols, so that's a valid return value that's handled
+	 * by the code below,  But if synth_count is < 0, this indicates
+	 * an error, so we return immediately.
+	 */
+	if (synth_count < 0)
+		return 0;
+
+	uint cur_symcount = (uint) synth_count + minisym_count;
+
+	asymbol ** symp;
+	asymbol ** new_mini;
+	    
+	new_mini = (asymbol **) malloc((cur_symcount + 1) * sizeof(*symp));
+	symp = new_mini;
+	memcpy(symp, minisyms, minisym_count * sizeof(*symp));
+	symp += minisym_count;
+
+	for (long i = 0; i < synth_count; i++)
+		*symp++ = synthsyms + i;
+	    
+	scoped_array<asymbol *> synth_syms;
+	synth_syms.reset(new asymbol * [cur_symcount + start]);
+
+	for (symbol_index_t i = 0; i < start; i++)
+		synth_syms[i + cur_symcount] = bfd_syms[i];
+	
+	for (symbol_index_t i = start; i < start + cur_symcount; i++)
+		synth_syms[i] = new_mini[i];
+   
+	bfd_syms.swap(synth_syms);
+	free(new_mini);
+
+	free(minisyms);
+
+	prev_total_symcount = cur_symcount;
+
+	return cur_symcount;
+
+}
+
+#else
+uint op_bfd::process_symtab(bfd * ibfd, size_t start) 
+{
+	return bfd_canonicalize_symtab(ibfd, bfd_syms.get() + start);
+}
+#endif
+
+
 void op_bfd::get_symbols_from_file(bfd * ibfd, size_t start,
    op_bfd::symbols_found_t & symbols, bool debug_file)
 {
 	uint nr_all_syms;
 
-	nr_all_syms = bfd_canonicalize_symtab(ibfd, bfd_syms.get()+start);
+	if (prev_total_symcount) 
+		start = prev_total_symcount;
+	nr_all_syms = process_symtab(ibfd, start);
 	if (nr_all_syms < 1)
 		return;
 
--- oprofile-0.8.2/libutil++/op_bfd.h.orig	2004-10-14 16:57:54.000000000 -0400
+++ oprofile-0.8.2/libutil++/op_bfd.h	2005-04-05 09:35:05.000000000 -0400
@@ -237,6 +237,18 @@
 
 	/// create an artificial symbol for a symbolless binary
 	op_bfd_symbol const create_artificial_symbol();
+
+        /* Generate symbols using bfd functions for
+	 * the image file associated with the ibfd arg.
+	 */
+	uint process_symtab(bfd * ibfd, size_t start);
+
+	/* Since process_symtab may occur twice for a given image file,
+	 * this instance variable may be used as needed to keep track
+	 * of the number of symbols generated in the previous call.
+	 */
+	uint prev_total_symcount;
+
 };
 
 /*


Index: oprofile.spec
===================================================================
RCS file: /cvs/dist/rpms/oprofile/devel/oprofile.spec,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- oprofile.spec	21 Mar 2005 15:29:19 -0000	1.26
+++ oprofile.spec	5 Apr 2005 14:00:50 -0000	1.27
@@ -1,6 +1,6 @@
-%define DATE 20050321
+%define DATE 20050405
 %define oprofile_version 0.8.2
-%define oprofile_release 2
+%define oprofile_release 3
 Summary: System wide profiler
 Name: oprofile
 Version: 0.8.2
@@ -15,6 +15,7 @@
 #Patch35: oprofile-0.4-separatedebug.patch
 Patch63: oprofile-0.7-libs.patch
 #Patch79: oprofile-0.8.1-power970.patch
+Patch80: oprofile-0.8.2-ppc64dot.patch
 
 URL: http://oprofile.sf.net
 ExclusiveArch: %{ix86} ia64 x86_64 ppc ppc64 s390 s390x
@@ -51,6 +52,7 @@
 %patch10 -p1 -b .guess2
 #%patch35 -p1 -b .separate
 %patch63 -p1 -b .libs
+%patch80 -p1 -b .ppc64dot
 
 ./autogen.sh
 
@@ -226,6 +228,9 @@
 
 
 %changelog
+* Tue Apr 05 2005 Will Cohen <wcohen at redhat.com>
+- Backport ppc64 patch for synthesizing dotted symbols.
+
 * Mon Mar 21 2005 Will Cohen <wcohen at redhat.com>
 - Bump release.
 - Rebase on 0.8.2 release.




More information about the fedora-cvs-commits mailing list