This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] ppc32 dl-machine.c
- From: Steve Munroe <sjmunroe at vnet dot ibm dot com>
- To: anton at samba dot org, libc-alpha at sources dot redhat dot com
- Cc: geoffk at geoffk dot org-c, roland at frob dot com
- Date: Tue, 24 Sep 2002 17:49:16 -0500
- Subject: [PATCH] ppc32 dl-machine.c
Back in July, Anton Blanchard reported a bug in dl-machine.c
(__elf_machine_runtime_setup) asserting that the loader must "icbi"
(Instruction Cache Block Invalidate) the entire PLT range after it is
initialized.
http://sources.redhat.com/ml/libc-alpha/2002-07/msg00166.html
Anton and Geoff Keating debated this back and forth for a while but I believe
the conclusion was that this is required based on the rationale in:
http://sources.redhat.com/ml/libc-alpha/2002-07/msg00180.html
I believe the discussion ended with Geoff expecting a patch from Anton.
But on examination of the the current CVS it seems Anton forgot. I discussed
this with Anton and offered to create the patch myself which is attached.
If this patch is accepted it should be considered for glibc-2-2-branch as
well as 2.3.
2002-09-24 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/powerpc32/dl-machine.c: Declare __cache_line_size as
weak extern.
(__elf_machine_runtime_setup): Invalidate the instruction cache over the
whole range of the PLT.
diff -rupPN -xCVS -x*orig -xmanual libc23-cvstip-20020923/sysdeps/powerpc/powerpc32/dl-machine.c libc23/sysdeps/powerpc/powerpc32/dl-machine.c
--- libc23-cvstip-20020923/sysdeps/powerpc/powerpc32/dl-machine.c Thu Sep 5 03:24:12 2002
+++ libc23/sysdeps/powerpc/powerpc32/dl-machine.c Tue Sep 24 16:42:46 2002
@@ -26,6 +26,11 @@
#include <dl-machine.h>
#include <stdio-common/_itoa.h>
+/* The value __cache_line_size is defined in memset.S and is initialised
+ by _dl_sysdep_start via DL_PLATFORM_INIT. */
+extern int __cache_line_size;
+weak_extern (__cache_line_size)
+
/* Because ld.so is now versioned, these functions can be in their own file;
no relocations need to be done to call them.
Of course, if ld.so is not versioned... */
@@ -214,6 +219,8 @@ __elf_machine_runtime_setup (struct link
Elf32_Word rel_offset_words = PLT_DATA_START_WORDS (num_plt_entries);
Elf32_Word data_words = (Elf32_Word) (plt + rel_offset_words);
Elf32_Word size_modified;
+ int *line_size_ptr = & __cache_line_size;
+ int words_per_line;
extern void _dl_runtime_resolve (void);
extern void _dl_prof_resolve (void);
@@ -304,14 +311,25 @@ __elf_machine_runtime_setup (struct link
there may be a little overlap at the start and the end.
Assumes that dcbst and icbi apply to lines of 16 bytes or
- more. Current known line sizes are 16, 32, and 128 bytes. */
+ more. Current known line sizes are 16, 32, and 128 bytes.
+ The following gets the __cache_line_size, when available. */
+ words_per_line = 4;/* Minimum 4 words per cache line. */
+ if (lazy) /* Don't try this until ld.so has relocated itself! */
+ if (line_size_ptr != NULL)
+ {
+ if (*line_size_ptr != 0) /* convert bytes to words. */
+ words_per_line = *line_size_ptr >> 2;
+ }
+
size_modified = lazy ? rel_offset_words : 6;
- for (i = 0; i < size_modified; i += 4)
- PPC_DCBST (plt + i);
+ for (i = 0; i < size_modified; i += words_per_line)
+ {
+ PPC_DCBST (plt + i);
+ PPC_ICBI (plt + i);
+ }
PPC_DCBST (plt + size_modified - 1);
PPC_SYNC;
- PPC_ICBI (plt);
PPC_ICBI (plt + size_modified - 1);
PPC_ISYNC;
}