aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog12
-rw-r--r--gas/as.h7
-rw-r--r--gas/dwarf2dbg.c19
-rw-r--r--gas/frags.c7
-rw-r--r--gas/symbols.c15
-rw-r--r--gas/write.c3
6 files changed, 52 insertions, 11 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 1751b00..b3affbb 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,17 @@
2019-11-25 Christian Eggers <ceggers@gmx.de>
+ * as.h: Define SEC_OCTETS as SEC_ELF_OCTETS if OBJ_ELF.
+ * dwarf2dbg.c: (dwarf2_finish): Set section flag SEC_OCTETS for
+ .debug_line, .debug_info, .debug_abbrev, .debug_aranges, .debug_str
+ and .debug_ranges sections.
+ * write.c (maybe_generate_build_notes): Set section flag
+ SEC_OCTETS for .gnu.build.attributes section.
+ * frags.c (frag_now_fix): Don't divide by OCTETS_PER_BYTE if
+ SEC_OCTETS is set.
+ * symbols.c (resolve_symbol_value): Likewise.
+
+2019-11-25 Christian Eggers <ceggers@gmx.de>
+
* dwarf2dbg.c (out_set_addr): Revert 2019-03-13 change.
(out_debug_line, out_debug_aranges, out_debug_info): Likewise.
* symbols.h (symbol_set_value_now_octets, symbol_octets_p): Remove.
diff --git a/gas/as.h b/gas/as.h
index 3c37519..3d492d4 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -649,4 +649,11 @@ COMMON int flag_sectname_subst;
#error "Octets per byte conflicts with its power-of-two definition!"
#endif
+#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
+/* On ELF platforms, mark debug sections with SEC_ELF_OCTETS */
+#define SEC_OCTETS (IS_ELF ? SEC_ELF_OCTETS : 0)
+#else
+#define SEC_OCTETS 0
+#endif
+
#endif /* GAS */
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index dce9603..001e2a1 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -2215,7 +2215,7 @@ dwarf2_finish (void)
/* Create and switch to the line number section. */
line_seg = subseg_new (".debug_line", 0);
- bfd_set_section_flags (line_seg, SEC_READONLY | SEC_DEBUGGING);
+ bfd_set_section_flags (line_seg, SEC_READONLY | SEC_DEBUGGING | SEC_OCTETS);
/* For each subsection, chain the debug entries together. */
for (s = all_segs; s; s = s->next)
@@ -2261,11 +2261,15 @@ dwarf2_finish (void)
aranges_seg = subseg_new (".debug_aranges", 0);
str_seg = subseg_new (".debug_str", 0);
- bfd_set_section_flags (info_seg, SEC_READONLY | SEC_DEBUGGING);
- bfd_set_section_flags (abbrev_seg, SEC_READONLY | SEC_DEBUGGING);
- bfd_set_section_flags (aranges_seg, SEC_READONLY | SEC_DEBUGGING);
- bfd_set_section_flags (str_seg, (SEC_READONLY | SEC_DEBUGGING
- | SEC_MERGE | SEC_STRINGS));
+ bfd_set_section_flags (info_seg,
+ SEC_READONLY | SEC_DEBUGGING | SEC_OCTETS);
+ bfd_set_section_flags (abbrev_seg,
+ SEC_READONLY | SEC_DEBUGGING | SEC_OCTETS);
+ bfd_set_section_flags (aranges_seg,
+ SEC_READONLY | SEC_DEBUGGING | SEC_OCTETS);
+ bfd_set_section_flags (str_seg,
+ SEC_READONLY | SEC_DEBUGGING | SEC_OCTETS
+ | SEC_MERGE | SEC_STRINGS);
str_seg->entsize = 1;
record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1);
@@ -2275,7 +2279,8 @@ dwarf2_finish (void)
else
{
ranges_seg = subseg_new (".debug_ranges", 0);
- bfd_set_section_flags (ranges_seg, SEC_READONLY | SEC_DEBUGGING);
+ bfd_set_section_flags (ranges_seg,
+ SEC_READONLY | SEC_DEBUGGING | SEC_OCTETS);
record_alignment (ranges_seg, ffs (2 * sizeof_address) - 1);
out_debug_ranges (ranges_seg);
}
diff --git a/gas/frags.c b/gas/frags.c
index 2f21b9d..f35cc80 100644
--- a/gas/frags.c
+++ b/gas/frags.c
@@ -395,7 +395,12 @@ frag_now_fix_octets (void)
addressT
frag_now_fix (void)
{
- return frag_now_fix_octets () / OCTETS_PER_BYTE;
+ /* Symbols whose section has SEC_ELF_OCTETS set,
+ resolve to octets instead of target bytes. */
+ if (now_seg->flags & SEC_OCTETS)
+ return frag_now_fix_octets ();
+ else
+ return frag_now_fix_octets () / OCTETS_PER_BYTE;
}
void
diff --git a/gas/symbols.c b/gas/symbols.c
index cff2405..857a3e6 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -1217,7 +1217,13 @@ resolve_symbol_value (symbolS *symp)
if (local_symbol_resolved_p (locsym))
return final_val;
- final_val += local_symbol_get_frag (locsym)->fr_address / OCTETS_PER_BYTE;
+ /* Symbols whose section has SEC_ELF_OCTETS set,
+ resolve to octets instead of target bytes. */
+ if (locsym->lsy_section->flags & SEC_OCTETS)
+ final_val += local_symbol_get_frag (locsym)->fr_address;
+ else
+ final_val += (local_symbol_get_frag (locsym)->fr_address
+ / OCTETS_PER_BYTE);
if (finalize_syms)
{
@@ -1330,7 +1336,12 @@ resolve_symbol_value (symbolS *symp)
/* Fall through. */
case O_constant:
- final_val += symp->sy_frag->fr_address / OCTETS_PER_BYTE;
+ /* Symbols whose section has SEC_ELF_OCTETS set,
+ resolve to octets instead of target bytes. */
+ if (symp->bsym->section->flags & SEC_OCTETS)
+ final_val += symp->sy_frag->fr_address;
+ else
+ final_val += symp->sy_frag->fr_address / OCTETS_PER_BYTE;
if (final_seg == expr_section)
final_seg = absolute_section;
/* Fall through. */
diff --git a/gas/write.c b/gas/write.c
index 8f7786e..d5da418 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1960,7 +1960,8 @@ maybe_generate_build_notes (void)
/* Create a GNU Build Attribute section. */
sec = subseg_new (GNU_BUILD_ATTRS_SECTION_NAME, FALSE);
elf_section_type (sec) = SHT_NOTE;
- bfd_set_section_flags (sec, SEC_READONLY | SEC_HAS_CONTENTS | SEC_DATA);
+ bfd_set_section_flags (sec, (SEC_READONLY | SEC_HAS_CONTENTS | SEC_DATA
+ | SEC_OCTETS));
bfd_set_section_alignment (sec, 2);
/* Work out the size of the notes that we will create,