linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* R_PPC_REL24 relocation out of range, with trivial program
@ 2000-03-02 23:25 Pierre Sarrazin
  0 siblings, 0 replies; 4+ messages in thread
From: Pierre Sarrazin @ 2000-03-02 23:25 UTC (permalink / raw)
  To: linuxppc-dev


This is another message about the "R_PPC_REL24 relocation out of range"
problem. I have a trivial program and library system that illustrates it.
I have read some of the previous messages on this topic but the solutions
proposed did not make a difference.

The problem happens when the dlopened library exports a C++
function returning 'string', but not when it exports a function
returning 'const char *'.

Here is the program:

--[ prog.cpp ]----------------------------------------------------------------
#include <assert.h>
#include <stdio.h>

#include <dlfcn.h>

#ifdef STRING_EXAMPLE
#include <string>
using namespace std;
#endif

int main()
{
	void *handle = dlopen("./libf.so", RTLD_NOW);
	if (!handle)
	{
		fprintf(stderr, "dlopen: %s\n", dlerror());
		return 1;
	}

	#ifdef STRING_EXAMPLE

	string (*pf)(void) = (string (*)(void)) dlsym(handle, "f");
	assert(pf);
	string s = (*pf)();
	printf("s = [%s]\n", s.c_str());

	#else

	const char *(*pg)(void) = (const char *(*)(void)) dlsym(handle, "g");
	assert(pg);
	const char *s = (*pg)();
	printf("s = [%s]\n", s);

	#endif

	dlclose(handle);

	return 0;
}
------------------------------------------------------------------------------

Here is the library source:

--[ f.cpp ]-------------------------------------------------------------------
#include <stdio.h>

#ifdef STRING_EXAMPLE

#include <string>

using namespace std;

extern "C" string f(void)
{
	printf("f()\n");
	return "pizza";
}

#else

extern "C" const char *g(void)
{
	printf("g()\n");
	return "spaghetti";
}

#endif
------------------------------------------------------------------------------


The Makefile defines STRING_EXAMPLE by default.  The problem only
occurs when it is defined. Here is the Makefile:


--[ Makefile ]----------------------------------------------------------------
# Program that illustrates the problem with the error message
# "R_PPC_REL24 relocation out of range" on LinuxPPC R5.
#
# By Pierre Sarrazin <sarrazip@iname.com> March 2, 2000.

FPIC=-fPIC
DEFINES=-DSTRING_EXAMPLE
CXXFLAGS=-g -Wall $(FPIC) $(DEFINES)

all: prog libf.so

prog: prog.o
	$(CXX) $(CXXFLAGS) -o $@ $< -ldl

prog.o: prog.cpp
	$(CXX) $(CXXFLAGS) -c $<

libf.so: f.o
	$(CXX) -shared -o $@ $<

f.o: f.cpp
	$(CXX) $(CXXFLAGS) -c $<

clean:
	rm prog prog.o libf.so f.o

distrib:
	tar czf R_PPC_REL24-relocation.tar.gz Makefile prog.cpp f.cpp
------------------------------------------------------------------------------


Here is a session on the LinuxPPC R5 machine. The compiler is
"gcc version 2.95.2 19991024 (release)". I have installed the
"binutils-2.9.5.0.14-0a" RPM.

------------------------------------------------------------------------------
$ make
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -c prog.cpp
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -o prog prog.o -ldl
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -c f.cpp
g++ -shared -o libf.so f.o
$ ./prog
dlopen: ./libf.so: R_PPC_REL24 relocation out of range
$ make clean
rm prog prog.o libf.so f.o
$ make DEFINES=
g++ -g -Wall -fPIC  -c prog.cpp
g++ -g -Wall -fPIC  -o prog prog.o -ldl
g++ -g -Wall -fPIC  -c f.cpp
g++ -shared -o libf.so f.o
$ ./prog
g()
s = [spaghetti]
$
------------------------------------------------------------------------------


Here is a session on a Pentium-based RedHat 5.2 system. It uses
"gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)" and
binutils-2.9.1.0.15-1.


------------------------------------------------------------------------------
$ make
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -c prog.cpp
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -o prog prog.o -ldl
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -c f.cpp
g++ -shared -o libf.so f.o
$ ./prog
f()
s = [pizza]
$
------------------------------------------------------------------------------


--
Pierre Sarrazin <sarrazip@machinasapiens.com>

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: R_PPC_REL24 relocation out of range, with trivial program
@ 2000-04-03 20:38 Pierre Sarrazin
  2000-04-03 20:46 ` David Edelsohn
  2000-04-03 21:34 ` Franz Sirl
  0 siblings, 2 replies; 4+ messages in thread
From: Pierre Sarrazin @ 2000-04-03 20:38 UTC (permalink / raw)
  To: linuxppc-dev


Last month I posted the following message:

From: Pierre Sarrazin
Date: Thu, 02 Mar 2000 18:25:46 -0500
> This is another message about the "R_PPC_REL24 relocation out of range"
> problem. I have a trivial program and library system that illustrates it.
> I have read some of the previous messages on this topic but the solutions
> proposed did not make a difference.
>
> The problem happens when the dlopened library exports a C++
> function returning 'string', but not when it exports a function
> returning 'const char *'.
>
> Here is the program:
	[...]


The full message is at:
http://lists.linuxppc.org/listarcs/linuxppc-dev/200003/msg00025.html


I would like to know if there is a chance that this problem will
be fixed soon. I have had to suspend my LinuxPPC work for the
last month. My company's support for the LinuxPPC platform is
delayed by this issue.

Is there a way to ask gcc to generate only long branch instructions
so as to avoid this whole problem? Thanks.

--
Pierre Sarrazin <sarrazip@machinasapiens.com>

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: R_PPC_REL24 relocation out of range, with trivial program
  2000-04-03 20:38 Pierre Sarrazin
@ 2000-04-03 20:46 ` David Edelsohn
  2000-04-03 21:34 ` Franz Sirl
  1 sibling, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2000-04-03 20:46 UTC (permalink / raw)
  To: Pierre Sarrazin; +Cc: linuxppc-dev


	This is not fixed with the most recent toolchain RPMs (both
binutils and gcc) avaliable?

David

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: R_PPC_REL24 relocation out of range, with trivial program
  2000-04-03 20:38 Pierre Sarrazin
  2000-04-03 20:46 ` David Edelsohn
@ 2000-04-03 21:34 ` Franz Sirl
  1 sibling, 0 replies; 4+ messages in thread
From: Franz Sirl @ 2000-04-03 21:34 UTC (permalink / raw)
  To: Pierre Sarrazin, linuxppc-dev


Am Mon, 03 Apr 2000 schrieb Pierre Sarrazin:
>Last month I posted the following message:
>
>From: Pierre Sarrazin
>Date: Thu, 02 Mar 2000 18:25:46 -0500
>> This is another message about the "R_PPC_REL24 relocation out of range"
>> problem. I have a trivial program and library system that illustrates it.
>> I have read some of the previous messages on this topic but the solutions
>> proposed did not make a difference.
>>
>> The problem happens when the dlopened library exports a C++
>> function returning 'string', but not when it exports a function
>> returning 'const char *'.
>>
>> Here is the program:
>	[...]
>
>
>The full message is at:
>http://lists.linuxppc.org/listarcs/linuxppc-dev/200003/msg00025.html
>
>
>I would like to know if there is a chance that this problem will
>be fixed soon. I have had to suspend my LinuxPPC work for the
>last month. My company's support for the LinuxPPC platform is
>delayed by this issue.
>
>Is there a way to ask gcc to generate only long branch instructions
>so as to avoid this whole problem? Thanks.

This seems to be fixed in the current toolchain:

[fsirl@entropy:~/bugs/reloc]$ make
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -c prog.cpp
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -o prog prog.o -ldl
g++ -g -Wall -fPIC -DSTRING_EXAMPLE -c f.cpp
g++ -shared -o libf.so f.o
[fsirl@entropy:~/bugs/reloc]$ ./prog
f()
s = [pizza]

Either upgrade your distribution or go to
<ftp://devel.linuxppc.org/users/fsirl>.

Franz.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-04-03 21:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-03-02 23:25 R_PPC_REL24 relocation out of range, with trivial program Pierre Sarrazin
  -- strict thread matches above, loose matches on Subject: below --
2000-04-03 20:38 Pierre Sarrazin
2000-04-03 20:46 ` David Edelsohn
2000-04-03 21:34 ` Franz Sirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).