Subject: a couple of toolchain questions
To: None <tech-toolchain@netbsd.org>
From: None <itojun@iijlab.net>
List: tech-toolchain
Date: 06/19/2002 08:08:50
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <16297.1024441726.1@itojun.org>
(1) is already solved. for (3), there was a comment on using intptr_t,
however it is not widely available. i have contacted binutils
developer about it.
itojun
------- =_aaaaaaaaaa0
Content-Type: message/rfc822
Content-ID: <16297.1024441726.2@itojun.org>
Content-Description: forwarded message
by coconut.itojun.org (Postfix) with SMTP id 80C984B24
for <itojun@itojun.org>; Tue, 18 Jun 2002 20:11:16 +0900 (JST)
by mail.netbsd.org with SMTP; 18 Jun 2002 11:10:58 -0000
by coconut.itojun.org (Postfix) with ESMTP id A13A34B24
for <tech-userlevel@netbsd.org>; Tue, 18 Jun 2002 20:10:56 +0900 (JST)
To: tech-userlevel@netbsd.org
Subject: couple of toolchain questions
From: itojun@iijlab.net
Date: Tue, 18 Jun 2002 20:10:56 +0900
Message-Id: <20020618111056.A13A34B24@coconut.itojun.org>
Sender: tech-userlevel-owner@netbsd.org
(1)
why do we have gnu/dist/toolchain/bfd/peigen.c in our repository?
it can be generated at runtime at ease, and there's no real
build tool issue (it can be generated by simple sed replacement).
in fact, it is generated on-demand during src/tools/toolchain build.
if noone objects, i would like to propose to remove it.
(i've put a rule to regenerate it in gnu/lib/libbfd/Makefile,
so it should be safe)
(2)
could I commit gnu/dist/toolchain/ld/deffilep.c, which is generated
from deffilep.y? gnu/usr.bin/binutils/ld/Makefile somehow forbids
us from generating .c from .y (.c.y rule is disabled).
it won't affect normal usage.
i guess .c.y rule is disabled to avoid build tool issue (like
buliding netbsd on platforms without yacc).
(3)
there seem to be pointer-casting bug (or portability issue) in
GNU toolchain. they try to cast void * (or whatever pointer) to
unsigned long long, under certain configuration, and it fails to
compile.
void *p;
unsigned long long x;
x = (unsigned long long)p;
i've modified my local tree as below, basically doing:
x = (unsigned long long)(unsigned long)p;
is it safe to commit this? if so, i would like to.
itojun
Index: dist/toolchain/gdb/infptrace.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gdb/infptrace.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 infptrace.c
--- dist/toolchain/gdb/infptrace.c 2000/07/26 00:32:47 1.1.1.1
+++ dist/toolchain/gdb/infptrace.c 2002/06/18 10:46:40
@@ -550,14 +550,14 @@
{
/* Need part of initial word -- fetch it. */
buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_pid),
- (PTRACE_ARG3_TYPE) addr, 0);
+ (PTRACE_ARG3_TYPE) (unsigned long) addr, 0);
}
if (count > 1) /* FIXME, avoid if even boundary */
{
buffer[count - 1]
= ptrace (PT_READ_I, PIDGET (inferior_pid),
- ((PTRACE_ARG3_TYPE)
+ ((PTRACE_ARG3_TYPE) (unsigned long)
(addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))),
0);
}
@@ -574,14 +574,14 @@
{
errno = 0;
ptrace (PT_WRITE_D, PIDGET (inferior_pid),
- (PTRACE_ARG3_TYPE) addr, buffer[i]);
+ (PTRACE_ARG3_TYPE) (unsigned long) addr, buffer[i]);
if (errno)
{
/* Using the appropriate one (I or D) is necessary for
Gould NP1, at least. */
errno = 0;
ptrace (PT_WRITE_I, PIDGET (inferior_pid),
- (PTRACE_ARG3_TYPE) addr, buffer[i]);
+ (PTRACE_ARG3_TYPE) (unsigned long) addr, buffer[i]);
}
if (errno)
return 0;
@@ -597,7 +597,7 @@
{
errno = 0;
buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_pid),
- (PTRACE_ARG3_TYPE) addr, 0);
+ (PTRACE_ARG3_TYPE) (unsigned long) addr, 0);
if (errno)
return 0;
QUIT;
Index: dist/toolchain/gdb/kcore-nbsd.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gdb/kcore-nbsd.c,v
retrieving revision 1.1
diff -u -r1.1 kcore-nbsd.c
--- dist/toolchain/gdb/kcore-nbsd.c 2000/08/02 21:00:33 1.1
+++ dist/toolchain/gdb/kcore-nbsd.c 2002/06/18 10:46:40
@@ -130,7 +130,7 @@
val = 0;
}
- return ((CORE_ADDR)val);
+ return ((CORE_ADDR) (unsigned long) val);
}
/*
@@ -384,7 +384,7 @@
if (kvread(addr, &val))
error("cannot read u area ptr");
- if (set_context((CORE_ADDR)val))
+ if (set_context((CORE_ADDR) (unsigned long) val))
error("invalid proc address");
}
Index: dist/toolchain/gprof/alpha.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gprof/alpha.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 alpha.c
--- dist/toolchain/gprof/alpha.c 2000/07/26 00:24:59 1.1.1.1
+++ dist/toolchain/gprof/alpha.c 2002/06/18 10:47:00
@@ -83,7 +83,7 @@
if (!delta)
{
- delta = (bfd_vma) core_text_space - core_text_sect->vma;
+ delta = (bfd_vma) (unsigned long)core_text_space - core_text_sect->vma;
sym_init (&indirect_child);
indirect_child.name = _("<indirect child>");
@@ -106,8 +106,8 @@
DBG (CALLDEBUG, printf (_("[find_call] %s: 0x%lx to 0x%lx\n"),
parent->name, (unsigned long) p_lowpc,
(unsigned long) p_highpc));
- for (pc = (alpha_Instruction *) (p_lowpc + delta);
- pc < (alpha_Instruction *) (p_highpc + delta);
+ for (pc = (alpha_Instruction *) (unsigned long)(p_lowpc + delta);
+ pc < (alpha_Instruction *) (unsigned long)(p_highpc + delta);
++pc)
{
switch (pc->a.op_code)
@@ -142,7 +142,7 @@
* the entry point by 8 bytes to skip loading the global
* pointer, so we all for either address:
*/
- dest_pc = ((bfd_vma) (pc + 1 + pc->b.disp)) - delta;
+ dest_pc = ((bfd_vma) (unsigned long)(pc + 1 + pc->b.disp)) - delta;
if (dest_pc >= s_lowpc && dest_pc <= s_highpc)
{
child = sym_lookup (&symtab, dest_pc);
Index: dist/toolchain/gprof/i386.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gprof/i386.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 i386.c
--- dist/toolchain/gprof/i386.c 2001/08/14 03:01:09 1.1.1.2
+++ dist/toolchain/gprof/i386.c 2002/06/18 10:47:00
@@ -58,17 +58,17 @@
parent->name, (unsigned long) p_lowpc,
(unsigned long) p_highpc));
- delta = (bfd_vma) core_text_space - core_text_sect->vma;
+ delta = (bfd_vma) (unsigned long)core_text_space - core_text_sect->vma;
- for (instructp = (unsigned char *) (p_lowpc + delta);
- instructp < (unsigned char *) (p_highpc + delta);
+ for (instructp = (unsigned char *) (unsigned long)(p_lowpc + delta);
+ instructp < (unsigned char *) (unsigned long)(p_highpc + delta);
instructp ++)
{
if (i386_iscall (instructp))
{
DBG (CALLDEBUG,
- printf ("[findcall]\t0x%lx:call",
- (unsigned long) (instructp - (unsigned char *) delta)));
+ printf ("[findcall]\t0x%llx:call",
+ (unsigned long) (instructp - (unsigned char *) (unsigned long) delta)));
/*
* regular pc relative addressing
* check that this is the address of
@@ -76,7 +76,7 @@
*/
destpc = ((bfd_vma) bfd_get_32 (core_bfd, instructp + 1)
- + (bfd_vma) instructp - (bfd_vma) delta + 5);
+ + (bfd_vma) (unsigned long)instructp - (bfd_vma) (unsigned long)delta + 5);
if (destpc >= s_lowpc && destpc <= s_highpc)
{
child = sym_lookup (&symtab, destpc);
Index: dist/toolchain/gprof/sparc.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gprof/sparc.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sparc.c
--- dist/toolchain/gprof/sparc.c 2000/07/26 00:25:03 1.1.1.1
+++ dist/toolchain/gprof/sparc.c 2002/06/18 10:47:00
@@ -37,7 +37,7 @@
unsigned int *instr;
Sym *child;
- delta = (bfd_vma) core_text_space - core_text_sect->vma;
+ delta = (bfd_vma) (unsigned long) core_text_space - core_text_sect->vma;
if (core_text_space == 0)
{
@@ -54,8 +54,8 @@
DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n",
parent->name, (unsigned long) p_lowpc,
(unsigned long) p_highpc));
- for (instr = (unsigned int *) (((p_lowpc + delta) + 3) &~ 3);
- instr < (unsigned int *) (p_highpc + delta);
+ for (instr = (unsigned int *) (unsigned long) (((p_lowpc + delta) + 3) &~ 3);
+ instr < (unsigned int *) (unsigned long) (p_highpc + delta);
++instr)
{
if ((*instr & CALL))
@@ -67,7 +67,7 @@
* Regular pc relative addressing check that this is the
* address of a function.
*/
- dest_pc = ((bfd_vma) (instr + (*instr & ~CALL))) - delta;
+ dest_pc = ((bfd_vma) (unsigned long) (instr + (*instr & ~CALL))) - delta;
if (dest_pc >= s_lowpc && dest_pc <= s_highpc)
{
child = sym_lookup (&symtab, dest_pc);
Index: dist/toolchain/gprof/tahoe.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gprof/tahoe.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 tahoe.c
--- dist/toolchain/gprof/tahoe.c 2001/08/14 03:01:14 1.1.1.2
+++ dist/toolchain/gprof/tahoe.c 2002/06/18 10:47:01
@@ -198,17 +198,17 @@
{
default:
fprintf (stderr, "[reladdr] not relative address\n");
- return (bfd_vma) modep;
+ return (bfd_vma) (unsigned long) modep;
case byterel:
- return (bfd_vma) (cp + sizeof *cp + *cp);
+ return (bfd_vma) (unsigned long) (cp + sizeof *cp + *cp);
case wordrel:
for (i = 0; (size_t) i < sizeof *sp; i++)
value = (value << 8) + (cp[i] & 0xff);
- return (bfd_vma) (cp + sizeof *sp + value);
+ return (bfd_vma) (unsigned long) (cp + sizeof *sp + value);
case longrel:
for (i = 0; (size_t) i < sizeof *lp; i++)
value = (value << 8) + (cp[i] & 0xff);
- return (bfd_vma) (cp + sizeof *lp + value);
+ return (bfd_vma) (unsigned long) (cp + sizeof *lp + value);
}
}
@@ -308,7 +308,7 @@
* a function.
*/
destpc = tahoe_reladdr (instructp + length)
- - (bfd_vma) core_text_space;
+ - (bfd_vma) (unsigned long) core_text_space;
if (destpc >= s_lowpc && destpc <= s_highpc)
{
child = sym_lookup (&symtab, destpc);
Index: dist/toolchain/gprof/vax.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gprof/vax.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 vax.c
--- dist/toolchain/gprof/vax.c 2001/08/14 03:01:15 1.1.1.2
+++ dist/toolchain/gprof/vax.c 2002/06/18 10:47:01
@@ -202,15 +202,15 @@
{
default:
fprintf (stderr, "[reladdr] not relative address\n");
- return (bfd_vma) modep;
+ return (bfd_vma) (unsigned long)modep;
case byterel:
- return (bfd_vma) (cp + sizeof *cp + *cp);
+ return (bfd_vma) (unsigned long)(cp + sizeof *cp + *cp);
case wordrel:
sp = (short *) cp;
- return (bfd_vma) (cp + sizeof *sp + *sp);
+ return (bfd_vma) (unsigned long)(cp + sizeof *sp + *sp);
case longrel:
lp = (long *) cp;
- return (bfd_vma) (cp + sizeof *lp + *lp);
+ return (bfd_vma) (unsigned long)(cp + sizeof *lp + *lp);
}
}
@@ -311,7 +311,7 @@
* a function.
*/
destpc = vax_reladdr ((struct modebyte *) (instructp + length))
- - (bfd_vma) core_text_space;
+ - (bfd_vma) (unsigned long) core_text_space;
if (destpc >= s_lowpc && destpc <= s_highpc)
{
child = sym_lookup (&symtab, destpc);
------- =_aaaaaaaaaa0--