This is the mail archive of the binutils@sourceware.org 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]

[Patch gas/mach-o] Generate relocs for local subtractions.


For mach-o, we must generate relocs, even for local subtractions - since we don't know (in general) until later whether the two symbols are going to be in the same sub-section.

OK?
Iain

gas:
	* config/obj-macho.c (obj_mach_o_is_frame_section): New.
	(obj_mach_o_allow_local_subtract): New.
	* config/obj-macho.h (md_allow_local_subtract): Define.
	(obj_mach_o_allow_local_subtract): Declare.

--- gas/config/obj-macho.c	2012-02-12 15:42:47.000000000 +0000
+++ gas/config/obj-macho-a.c	2012-02-18 11:30:56.000000000 +0000
@@ -1483,6 +1483,19 @@
   return 0;
 }

+/* Relocation rules are different in frame sections. */
+
+static int
+obj_mach_o_is_frame_section (segT sec)
+{
+ int l;
+ l = strlen (segment_name (sec));
+ if ((l == 9 && strncmp (".eh_frame", segment_name (sec), 9) == 0)
+ || (l == 12 && strncmp (".debug_frame", segment_name (sec), 12) == 0))
+ return 1;
+ return 0;
+}
+
/* Zerofill and GB Zerofill sections must be sorted to follow all other
sections in their segments.


@@ -1745,3 +1758,21 @@
/* It's a debug symbol. */
s->symbol.flags |= BSF_DEBUGGING;
}
+
+/* Unless we're in a frame section, we need to force relocs to be generated for
+ local subtractions. We might eliminate them later (if they are within the
+ same sub-section) but we don't know that at the point that this decision is
+ being made. */
+
+int
+obj_mach_o_allow_local_subtract (expressionS * left ATTRIBUTE_UNUSED,
+ expressionS * right ATTRIBUTE_UNUSED,
+ segT seg)
+{
+ /* Don't interfere if it's one of the GAS internal sections. */
+ if (! SEG_NORMAL (seg))
+ return 1;
+
+ /* Allow in frame sections, otherwise emit a reloc. */
+ return obj_mach_o_is_frame_section (seg);
+}
--- gas/config/obj-macho.h 2012-01-13 15:14:10.000000000 +0000
+++ gas/config/obj-macho-a.h 2012-02-18 11:33:38.000000000 +0000
@@ -73,6 +73,12 @@
#define SET_SECTION_RELOCS(sec, relocs, n) \
obj_mach_o_reorder_section_relocs (sec, relocs, n)


+/* Emit relocs for local subtracts, to cater for subsections-via- symbols. */
+#define md_allow_local_subtract(LEFT, RIGHT, SECTION) \
+ obj_mach_o_allow_local_subtract (LEFT, RIGHT, SECTION)
+extern int obj_mach_o_allow_local_subtract (expressionS *, expressionS *,
+ segT);
+
#define EMIT_SECTION_SYMBOLS 0


#define OBJ_PROCESS_STAB(SEG,W,S,T,O,D) obj_mach_o_process_stab(W,S,T,O,D)


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