[BZ,#19178] Add a test for prelink output

Message ID 20151107145502.GA959@intel.com
State New, archived
Headers

Commit Message

Lu, Hongjiu Nov. 7, 2015, 2:55 p.m. UTC
  This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.  OK for
master?

H.J.

	[BZ #19178]
	* sysdeps/x86/Makefile (tests): Add tst-prelink.
	(tst-prelink-ENV): New.
	($(objpfx)tst-prelink-conflict.out): Likewise.
	($(objpfx)tst-prelink-cmp.out): Likewise.
	(tests-special): Add $(objpfx)tst-prelink-cmp.out.
	* sysdeps/x86/tst-prelink.c: New file.
	* sysdeps/x86/tst-prelink.exp: Likewise.
---
 sysdeps/x86/Makefile        | 15 +++++++++++++++
 sysdeps/x86/tst-prelink.c   | 14 ++++++++++++++
 sysdeps/x86/tst-prelink.exp |  1 +
 3 files changed, 30 insertions(+)
 create mode 100644 sysdeps/x86/tst-prelink.c
 create mode 100644 sysdeps/x86/tst-prelink.exp
  

Comments

Szabolcs Nagy Nov. 7, 2015, 3:54 p.m. UTC | #1
* H.J. Lu <hongjiu.lu@intel.com> [2015-11-07 06:55:02 -0800]:
> This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
> R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.  OK for
> master?
> 

why is the test x86 specific?

extern protected data handling and LD_TRACE_PRELINKING
seem to be generic.
  
H.J. Lu Nov. 9, 2015, 2:42 p.m. UTC | #2
On Sat, Nov 7, 2015 at 7:54 AM, Szabolcs Nagy <nsz@port70.net> wrote:
> * H.J. Lu <hongjiu.lu@intel.com> [2015-11-07 06:55:02 -0800]:
>> This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
>> R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.  OK for
>> master?
>>
>
> why is the test x86 specific?
>
> extern protected data handling and LD_TRACE_PRELINKING
> seem to be generic.

It only applies to GLOB_DAT relocation.  Not all targets have it
and I have only x86 to test.
  
H.J. Lu Nov. 10, 2015, 8:30 p.m. UTC | #3
On Mon, Nov 9, 2015 at 6:42 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Nov 7, 2015 at 7:54 AM, Szabolcs Nagy <nsz@port70.net> wrote:
>> * H.J. Lu <hongjiu.lu@intel.com> [2015-11-07 06:55:02 -0800]:
>>> This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
>>> R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.  OK for
>>> master?
>>>
>>
>> why is the test x86 specific?
>>
>> extern protected data handling and LD_TRACE_PRELINKING
>> seem to be generic.
>
> It only applies to GLOB_DAT relocation.  Not all targets have it
> and I have only x86 to test.
>

I will check it in and backport the fix with this this to 2.22 branch.
  
Joseph Myers Nov. 10, 2015, 9:43 p.m. UTC | #4
On Tue, 10 Nov 2015, H.J. Lu wrote:

> On Mon, Nov 9, 2015 at 6:42 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > On Sat, Nov 7, 2015 at 7:54 AM, Szabolcs Nagy <nsz@port70.net> wrote:
> >> * H.J. Lu <hongjiu.lu@intel.com> [2015-11-07 06:55:02 -0800]:
> >>> This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
> >>> R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.  OK for
> >>> master?
> >>>
> >>
> >> why is the test x86 specific?
> >>
> >> extern protected data handling and LD_TRACE_PRELINKING
> >> seem to be generic.
> >
> > It only applies to GLOB_DAT relocation.  Not all targets have it
> > and I have only x86 to test.
> >
> 
> I will check it in and backport the fix with this this to 2.22 branch.

I see no sign of consensus for an x86-specific test here.  I too think the 
test should be written in an architecture-independent way, with a way for 
architectures for which it is inapplicable to disable it.

Stop committing patches that do not have consensus, whether through 
discussion or through being one of the kinds of changes listed at 
<https://sourceware.org/glibc/wiki/Consensus#Trivial_Bug-Fix_Changes>.  
Write access is granted only on the basis that people will understand and 
work in accordance with agreed policies for use of the repository.
  

Patch

diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index 0de4f42..a2f4f8a 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -7,4 +7,19 @@  sysdep-dl-routines += dl-get-cpu-features
 
 tests += tst-get-cpu-features
 tests-static += tst-get-cpu-features-static
+
+tests += tst-prelink
+tst-prelink-ENV = LD_TRACE_PRELINKING=1
+
+$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out
+	grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@
+
+$(objpfx)tst-prelink-cmp.out: $(..)sysdeps/x86/tst-prelink.exp \
+			      $(objpfx)tst-prelink-conflict.out
+	cmp $^ > $@; \
+	$(evaluate-test)
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)tst-prelink-cmp.out
+endif
 endif
diff --git a/sysdeps/x86/tst-prelink.c b/sysdeps/x86/tst-prelink.c
new file mode 100644
index 0000000..482285c
--- /dev/null
+++ b/sysdeps/x86/tst-prelink.c
@@ -0,0 +1,14 @@ 
+/* Test the output from the environment variable, LD_TRACE_PRELINKING,
+   for prelink.  */
+
+#include <stdio.h>
+
+static int
+do_test (void)
+{
+  fprintf (stdout, "hello\n");
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/sysdeps/x86/tst-prelink.exp b/sysdeps/x86/tst-prelink.exp
new file mode 100644
index 0000000..b35b4c9
--- /dev/null
+++ b/sysdeps/x86/tst-prelink.exp
@@ -0,0 +1 @@ 
+/0 stdout