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]
Other format: [Raw text]

Re: PATCH: BZ/175: Fix dynamic string offset


On Fri, May 28, 2004 at 11:21:22PM -0700, Jim Wilson wrote:
> 
> HJ's example uses an LTOFF22X relocation, there is nothing particularly
> special about that.  I don't think you can determine anything special by
> looking at the relocation here.
> 
> HJ's example looks like it is generating an address outside an object,
> which is only valid if it is later given an offset that puts us back
> inside the object again.  In this case either we shouldn't be generating
> an error for out-of-bounds addresses, or else we shouldn't be generating
> out-of-bounds addresses for mergeable sections.  The second one implies
> a compiler fix, probably not merging offsets with symbols in a CONST if
> the offset takes us outside the object, and the object is in a mergable
> section.  The first one implies that we need to differentiate between
> internal offsets and programmer supplied offsets.  Internal offsets give
> an error if they go outside the mergable section because that indicates
> a bug, but programmer supplied offsets do not, because the programmer
> meant to do that.  I think one of HJ's patches tried to implement
> something like this.

I think Alan may be right. I backed out my patch for the time being. I
think we should pass r_addend to _bfd_merged_section_offset only for
section symbols. For local and global symbols, merge will adjust their
st_values. We shouldn't pass r_addend against them to
_bfd_merged_section_offset.



H.J.
----
--- elfxx-ia64.c.old	2004-05-29 12:54:53.513336759 -0700
+++ elfxx-ia64.c	2004-05-29 12:58:01.789929194 -0700
@@ -875,12 +875,18 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	  toff = isym->st_value;
 	  dyn_i = get_dyn_sym_info (ia64_info, NULL, abfd, irel, FALSE);
 	  
-	  if ((tsec->flags & SEC_MERGE)
-	      && ELF_ST_TYPE (isym->st_info) == STT_SECTION
-	      && tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
-	    toff = _bfd_merged_section_offset (abfd, &tsec,
-					       elf_section_data (tsec)->sec_info,
-					       toff + irel->r_addend);
+	  if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
+	    {
+	      if ((tsec->flags & SEC_MERGE)
+		  && ELF_ST_TYPE (isym->st_info) == STT_SECTION)
+		toff = _bfd_merged_section_offset (abfd, &tsec,
+						   elf_section_data (tsec)->sec_info,
+						   toff + irel->r_addend);
+	      else
+		toff = _bfd_merged_section_offset (abfd, &tsec,
+						   elf_section_data (tsec)->sec_info,
+						   toff) + irel->r_addend;
+	    }
 	  else
 	    toff += irel->r_addend;
 	}
@@ -931,7 +937,7 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	  if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
 	    toff = _bfd_merged_section_offset (abfd, &tsec,
 					       elf_section_data (tsec)->sec_info,
-					       toff + irel->r_addend);
+					       toff) + irel->r_addend;
 	  else
 	    toff += irel->r_addend;
 	}


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