From adsharma@unix-os.sc.intel.com  Thu Feb  6 18:04:50 2003
Return-Path: <adsharma@unix-os.sc.intel.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 90D8437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  6 Feb 2003 18:04:50 -0800 (PST)
Received: from caduceus.sc.intel.com (fmr04.intel.com [143.183.121.6])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0A03043F85
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  6 Feb 2003 18:04:50 -0800 (PST)
	(envelope-from adsharma@unix-os.sc.intel.com)
Received: from talaria.sc.intel.com (talaria.sc.intel.com [10.3.253.5])
	by caduceus.sc.intel.com (8.11.6/8.11.6/d: outer.mc,v 1.51 2002/09/23 20:43:23 dmccart Exp $) with ESMTP id h1723o518071
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 7 Feb 2003 02:03:50 GMT
Received: from unix-os.sc.intel.com (unix-os.sc.intel.com [143.183.96.244])
	by talaria.sc.intel.com (8.11.6/8.11.6/d: inner.mc,v 1.28 2003/01/13 19:44:39 dmccart Exp $) with ESMTP id h1720mR27637
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 7 Feb 2003 02:00:48 GMT
Received: (from adsharma@localhost)
	by unix-os.sc.intel.com (8.11.6/8.11.2) id h1724nZ09232
	for FreeBSD-gnats-submit@freebsd.org; Thu, 6 Feb 2003 18:04:49 -0800
Message-Id: <20030206180449.A9223@unix-os.sc.intel.com>
Date: Thu, 6 Feb 2003 18:04:49 -0800
From: Arun Sharma <arun.sharma@intel.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: function pointer has different values in libraries vs main program
X-Send-Pr-Version: 3.113

>Number:         48024
>Category:       ia64
>Synopsis:       function pointer has different values in libraries vs main program
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ia64
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 06 18:10:10 PST 2003
>Closed-Date:    Thu Mar 20 17:08:15 PST 2003
>Last-Modified:  Thu Mar 20 17:08:15 PST 2003
>Originator:     Arun Sharma
>Release:        FreeBSD 5.0-CURRENT ia64
>Organization:
Myself
>Environment:

System: FreeBSD adsharma-ia64 5.0-CURRENT FreeBSD 5.0-CURRENT #3: Wed Jan 22 12:40:09 GMT 2003 adsharma@adsharma-ia64:/usr/src/sys/ia64/compile/bigsur ia64


>Description:
	The program below prints different values for the value of &foo1, when called from a
	shared lib vs main program.

>How-To-Repeat:
	unshar
	make
	./main
>Fix:

	Not known yet.


# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	test
#	test/foo.c
#	test/main.c
#	test/Makefile
#
echo c - test
mkdir -p test > /dev/null 2>&1
echo x - test/foo.c
sed 's/^X//' >test/foo.c << 'END-of-test/foo.c'
X#include <stdio.h>
X
Xint 
Xfoo1()
X{
X}
X
Xint
Xfoo()
X{
X	int (*fptr)();
X
X	fptr = &foo1;
X 
X	printf("foo1 is at %lx: \n", foo1);
X}
END-of-test/foo.c
echo x - test/main.c
sed 's/^X//' >test/main.c << 'END-of-test/main.c'
X#include <stdio.h>
X
X
Xextern int foo1();
X
Xmain()
X{
X	int (*fptr)();
X
X	foo();
X	fptr = &foo1;
X	printf("foo1 is at %lx: \n", foo1);
X}
END-of-test/main.c
echo x - test/Makefile
sed 's/^X//' >test/Makefile << 'END-of-test/Makefile'
Xall:
X	gcc -c -fPIC foo.c -o foo.o
X	gcc -shared foo.o -o libfoo.so
X	gcc main.c -L. -lfoo -o main
X
END-of-test/Makefile
exit


>Release-Note:
>Audit-Trail:

From: Marcel Moolenaar <marcel@xcllnt.net>
To: Arun Sharma <arun.sharma@intel.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: ia64/48024: function pointer has different values in libraries vs main program
Date: Thu, 6 Feb 2003 19:30:17 -0800

 On Thu, Feb 06, 2003 at 06:04:49PM -0800, Arun Sharma wrote:
 > 
 > >Fix:
 
 See /usr/src/libexec/rtld-elf/ia64/reloc.c, lines 145 and 443
 for example.
 
 We create function descriptors on a per-load module basis. Hence,
 function addresses will not generally be the same when taken
 from different load modules, but will generally be the same when
 taken from the same load module. It's a known issue.
 
 Thanks for the tracker! We've been way too sloppy about this :-)
 
 -- 
  Marcel Moolenaar	  USPA: A-39004		 marcel@xcllnt.net
State-Changed-From-To: open->closed 
State-Changed-By: arun 
State-Changed-When: Thu Mar 20 17:06:31 PST 2003 
State-Changed-Why:  

Fixed by 

Revision  Changes    Path 
1.12      +77 -52    src/libexec/rtld-elf/ia64/reloc.c 


http://www.freebsd.org/cgi/query-pr.cgi?pr=48024 
>Unformatted:
