This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: PATCH: More protected symbol tests
- From: "H. J. Lu" <hjl at lucon dot org>
- To: GNU C Library <libc-alpha at sources dot redhat dot com>,binutils at sources dot redhat dot com
- Date: Wed, 26 Mar 2003 13:40:25 -0800
- Subject: Re: PATCH: More protected symbol tests
- References: <20030326122909.A10176@lucon.org>
On Wed, Mar 26, 2003 at 12:29:09PM -0800, H. J. Lu wrote:
> glibc/ld don't handle addresss of some protected symbols right. Here is
> a testcase for glibc. I am not certain where the bug is. It could be
> in glibc and/or ld.
>
Here is an update for my last patch. It turns out we aren't testing
addresses of variables at all. We just test their values which happen
to be addresses of some strings. This patch fixes the testcase. It
is a glibc bug. I will post a patch later.
H.J.
---
2003-03-26 H.J. Lu <hjl at gnu dot org>
* elf/vismod.h (getvarlocal1): Return const char **.
(getvarinmod1): Likewise.
(getvaritcpt1): Likewise.
(getvarlocal2): Likewise.
(getvarinmod2): Likewise.
(getvaritcpt2): Likewise.
(getvaritcpt3): Likewise.
* elf/vismain.c (do_test): Adjusted.
* elf/vismod1.c (getvarlocal1): Return address.
(getvarinmod1): Likewise.
(getvaritcpt1): Likewise.
* elf/vismod2.c (getvarlocal2): Likewise.
(getvarinmod2): Likewise.
(getvaritcpt2): Likewise.
* elf/vismod3.c (getvaritcpt3): Likewise.
--- elf/vismain.c.protected 2001-07-05 21:54:46.000000000 -0700
+++ elf/vismain.c 2003-03-26 13:31:13.000000000 -0800
@@ -150,12 +150,12 @@ pointers to `protitcpt' in mod1 or mod2
/* Now look at variables. First a variable which is available
everywhere. We must have three different addresses. */
- if (protvarlocal == getvarlocal1 ())
+ if (&protvarlocal == getvarlocal1 ())
{
puts ("`protvarlocal' in main and mod1 have same address");
res = 1;
}
- if (protvarlocal == getvarlocal2 ())
+ if (&protvarlocal == getvarlocal2 ())
{
puts ("`protvarlocal' in main and mod2 have same address");
res = 1;
@@ -170,53 +170,53 @@ pointers to `protitcpt' in mod1 or mod2
puts ("`protvarlocal in main has wrong value");
res = 1;
}
- if (strcmp (getvarlocal1 (), "vismod1.c") != 0)
+ if (strcmp (*getvarlocal1 (), "vismod1.c") != 0)
{
puts ("`getvarlocal1' returns wrong value");
res = 1;
}
- if (strcmp (getvarlocal2 (), "vismod2.c") != 0)
+ if (strcmp (*getvarlocal2 (), "vismod2.c") != 0)
{
puts ("`getvarlocal2' returns wrong value");
res = 1;
}
/* Now the case where there is no local definition. */
- if (protvarinmod != getvarinmod1 ())
+ if (&protvarinmod != getvarinmod1 ())
{
- puts ("`protvarinmod' in main and mod1 have not same address");
+ puts ("`protvarinmod' in main and mod1 don't have same address");
res = 1;
}
- if (protvarinmod == getvarinmod2 ())
+ if (&protvarinmod == getvarinmod2 ())
{
puts ("`protvarinmod' in main and mod2 have same address");
res = 1;
}
- if (strcmp (getvarinmod1 (), "vismod1.c") != 0)
+ if (strcmp (*getvarinmod1 (), "vismod1.c") != 0)
{
puts ("`getvarinmod1' returns wrong value");
res = 1;
}
- if (strcmp (getvarinmod2 (), "vismod2.c") != 0)
+ if (strcmp (*getvarinmod2 (), "vismod2.c") != 0)
{
puts ("`getvarinmod2' returns wrong value");
res = 1;
}
/* And a test where a variable definition is intercepted. */
- if (protvaritcpt == getvaritcpt1 ())
+ if (&protvaritcpt == getvaritcpt1 ())
{
puts ("`protvaritcpt' in main and mod1 have same address");
res = 1;
}
- if (protvaritcpt == getvaritcpt2 ())
+ if (&protvaritcpt == getvaritcpt2 ())
{
puts ("`protvaritcpt' in main and mod2 have same address");
res = 1;
}
- if (protvaritcpt != getvaritcpt3 ())
+ if (&protvaritcpt != getvaritcpt3 ())
{
- puts ("`protvaritcpt' in main and mod3 have not same address");
+ puts ("`protvaritcpt' in main and mod3 don't have same address");
res = 1;
}
if (getvaritcpt1 () == getvaritcpt2 ())
@@ -229,12 +229,12 @@ pointers to `protitcpt' in mod1 or mod2
puts ("`protvaritcpt in main has wrong value");
res = 1;
}
- if (strcmp (getvaritcpt1 (), "vismod1.c") != 0)
+ if (strcmp (*getvaritcpt1 (), "vismod1.c") != 0)
{
puts ("`getvaritcpt1' returns wrong value");
res = 1;
}
- if (strcmp (getvaritcpt2 (), "vismod2.c") != 0)
+ if (strcmp (*getvaritcpt2 (), "vismod2.c") != 0)
{
puts ("`getvaritcpt2' returns wrong value");
res = 1;
--- elf/vismod.h.protected 2000-12-17 09:07:45.000000000 -0800
+++ elf/vismod.h 2003-03-26 13:33:12.000000000 -0800
@@ -5,21 +5,21 @@ extern int callinmod1 (void);
extern int (*getinmod1 (void)) (void);
extern int callitcpt1 (void);
extern int (*getitcpt1 (void)) (void);
-extern const char *getvarlocal1 (void);
-extern const char *getvarinmod1 (void);
-extern const char *getvaritcpt1 (void);
+extern const char **getvarlocal1 (void);
+extern const char **getvarinmod1 (void);
+extern const char **getvaritcpt1 (void);
extern int calllocal2 (void);
extern int (*getlocal2 (void)) (void);
extern int callinmod2 (void);
extern int (*getinmod2 (void)) (void);
extern int callitcpt2 (void);
extern int (*getitcpt2 (void)) (void);
-extern const char *getvarlocal2 (void);
-extern const char *getvarinmod2 (void);
-extern const char *getvaritcpt2 (void);
+extern const char **getvarlocal2 (void);
+extern const char **getvarinmod2 (void);
+extern const char **getvaritcpt2 (void);
extern int callitcpt3 (void);
extern int (*getitcpt3 (void)) (void);
-extern const char *getvaritcpt3 (void);
+extern const char **getvaritcpt3 (void);
extern int protinmod (void);
extern int protitcpt (void);
--- elf/vismod1.c.protected 2001-07-05 21:54:46.000000000 -0700
+++ elf/vismod1.c 2003-03-26 13:27:57.000000000 -0800
@@ -79,26 +79,26 @@ int
const char *protvarlocal = __FILE__;
asm (".protected protvarlocal");
-const char *
+const char **
getvarlocal1 (void)
{
- return protvarlocal;
+ return &protvarlocal;
}
const char *protvarinmod = __FILE__;
asm (".protected protvarinmod");
-const char *
+const char **
getvarinmod1 (void)
{
- return protvarinmod;
+ return &protvarinmod;
}
const char *protvaritcpt = __FILE__;
asm (".protected protvaritcpt");
-const char *
+const char **
getvaritcpt1 (void)
{
- return protvaritcpt;
+ return &protvaritcpt;
}
--- elf/vismod2.c.protected 2001-07-05 21:54:46.000000000 -0700
+++ elf/vismod2.c 2003-03-26 13:30:07.000000000 -0800
@@ -80,28 +80,28 @@ int
const char *protvarlocal = __FILE__;
asm (".protected protvarlocal");
-const char *
+const char **
getvarlocal2 (void)
{
- return protvarlocal;
+ return &protvarlocal;
}
const char *protvarinmod = __FILE__;
asm (".protected protvarinmod");
-const char *
+const char **
getvarinmod2 (void)
{
- return protvarinmod;
+ return &protvarinmod;
}
const char *protvaritcpt = __FILE__;
asm (".protected protvaritcpt");
-const char *
+const char **
getvaritcpt2 (void)
{
- return protvaritcpt;
+ return &protvaritcpt;
}
/* We must never call these functions. */
@@ -117,7 +117,7 @@ int
abort ();
}
-const char *
+const char **
getvaritcpt3 (void)
{
abort ();
--- elf/vismod3.c.protected 2001-07-05 21:54:46.000000000 -0700
+++ elf/vismod3.c 2003-03-26 13:29:14.000000000 -0800
@@ -40,8 +40,8 @@ int
const char *protvaritcpt = __FILE__;
asm (".protected protvaritcpt");
-const char *
+const char **
getvaritcpt3 (void)
{
- return protvaritcpt;
+ return &protvaritcpt;
}