]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-avr.c
Fix AVR assembler so that it creates relocs that will work with linker relaxation.
[thirdparty/binutils-gdb.git] / gas / config / tc-avr.c
index e731ea9b7d9d482e43aeb54d0bcad8c7d29fc51e..f5fe659130f8212ee33e14f487efc7e3ddd718d4 100644 (file)
@@ -2820,3 +2820,29 @@ avr_pre_output_hook (void)
   if (avr_opt.have_gccisr)
     bfd_map_over_sections (stdoutput, avr_check_gccisr_done, NULL);
 }
+
+/* Return false if the fixup in fixp should be left alone and not
+   adjusted.  */
+
+bool
+avr_fix_adjustable (struct fix *fixp)
+{
+  if (! linkrelax || fixp->fx_addsy == NULL)
+    return true;
+
+  /* Do not adjust relocations involving symbols in code sections,
+     because it breaks linker relaxations.  This could be fixed in the
+     linker, but this fix is simpler, and it pretty much only affects
+     object size a little bit.  */
+  if (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_CODE)
+    return false;
+
+  /* Likewise, do not adjust symbols that won't be merged, or debug
+     symbols, because they too break relaxation.  We do want to adjust
+     other mergeable symbols, like .rodata, because code relaxations
+     need section-relative symbols to properly relax them.  */
+  if (! (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_MERGE))
+    return false;
+
+  return true;
+}