This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH for i386: --no-copy-relocs


On Sat, Jun 23, 2001 at 03:21:25PM -0700, H . J . Lu wrote:
> On Sat, Jun 23, 2001 at 02:55:51AM +0930, Alan Modra wrote:
> > On Thu, Jun 21, 2001 at 05:33:25PM -0700, Ian Lance Taylor wrote:
> > > 
> > > If a symbol is only referenced from writable sections, then omitting
> > > the COPY relocation is OK because those sections can not be shared anyhow.
> > 
> > Here's a first pass at this change.  Not overmuch tested yet ;)
> > but I need to sleep.  HJ, you said you'd happily test this for me,
> > so here it is.  ChangeLog coming later.
> > 
> > 
> 
> Here is a testcase.
> 
> # make 
> gcc -O -g -fPIC   -c -o main.o main.c
> gcc -O -g -fPIC   -c -o foo.o foo.c
> gcc -static -o foo main.o foo.o
> for f in foo; do echo "Running: $f"; ./$f; \
>   if [ $? != 0 ]; then echo Failed; fi; done
> Running: foo
> Failed
> # ./foo
> zsh: 1862 segmentation fault  ./foo
> 
> 
> I am looking into it now.
> 
> 
> H.J.

Alan,

This patch seems to work for me. The condition we want to check is
a symbol is defined, but not defined in the regular object. I think we
should check ELF_LINK_HASH_DEF_DYNAMIC, not ELF_LINK_HASH_DEF_REGULAR
since the common symbol in the regular object won't set
ELF_LINK_HASH_DEF_REGULAR.

I will also check if it handls the weak symbol right.


H.J.
--- elf32-i386.c.new	Sat Jun 23 16:44:18 2001
+++ elf32-i386.c	Sat Jun 23 16:46:54 2001
@@ -1694,8 +1694,9 @@ elf_i386_relocate_section (output_bfd, i
 		  && h->dynindx != -1
 		  && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
 		  && (h->root.type == bfd_link_hash_defweak
-		      || (h->elf_link_hash_flags
-			  & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+		      || (h->root.type == bfd_link_hash_defined
+			  && (h->elf_link_hash_flags
+			      & ELF_LINK_HASH_DEF_DYNAMIC) != 0))))
 	    {
 	      Elf_Internal_Rel outrel;
 	      boolean skip, relocate;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]