/* Set an absolute address (may result in a relocation entry). */
+static void
+out_inc_line_addr (int line_delta, addressT addr_delta);
+
static void
out_set_addr (symbolS *sym)
{
expressionS exp;
+ addressT expr_addr, expr_addr_aligned;
memset (&exp, 0, sizeof exp);
- out_opcode (DW_LNS_extended_op);
- out_uleb128 (sizeof_address + 1);
- out_opcode (DW_LNE_set_address);
+ /* The expression at the bottom must be aligned to OCTETS_PER_BYTE. The
+ statements after the for loop will contribute 3 more octets. */
+ expr_addr = frag_now_fix_octets () + 3;
+ expr_addr_aligned = (expr_addr + OCTETS_PER_BYTE - 1) & -OCTETS_PER_BYTE;
+ for ( ; expr_addr != expr_addr_aligned; expr_addr++)
+ out_inc_line_addr (0, 0); /* NOP */
+
+ out_opcode (DW_LNS_extended_op); /* 1 octet */
+ out_uleb128 (sizeof_address + 1); /* 1 octet */
+
+ out_opcode (DW_LNE_set_address); /* 1 octet */
exp.X_op = O_symbol;
exp.X_add_symbol = sym;
exp.X_add_number = 0;
symbolS *line_end;
struct line_seg *s;
int sizeof_offset;
+ addressT section_end, section_end_aligned;
memset (&exp, 0, sizeof exp);
sizeof_offset = out_header (line_seg, &exp);
in the DWARF Line Number header. */
subseg_set (subseg_get (".debug_line_end", FALSE), 0);
+ /* Pad size of .debug_line section to a multiple of OCTETS_PER_BYTE.
+ Simply sizing the section in md_section_align() is not sufficient,
+ also the size field in the .debug_line header must be a multiple
+ of OCTETS_PER_BYTE. Not doing so will introduce gaps within the
+ .debug_line sections after linking. */
+ section_end = frag_now_fix_octets ();
+ section_end_aligned = (section_end + OCTETS_PER_BYTE - 1) & -OCTETS_PER_BYTE;
+ for ( ; section_end != section_end_aligned; section_end++)
+ out_inc_line_addr (0, 0); /* NOP */
+
symbol_set_value_now_octets (line_end);
}
on the command line, so assume files[1] is the main input file.
We're not supposed to get called unless at least one line number
entry was emitted, so this should always be defined. */
- *name_sym = symbol_temp_new_now ();
+ *name_sym = symbol_temp_new_now_octets ();
if (files_in_use == 0)
abort ();
if (files[1].dir)
memcpy (p, files[1].filename, len);
/* DW_AT_comp_dir */
- *comp_dir_sym = symbol_temp_new_now ();
+ *comp_dir_sym = symbol_temp_new_now_octets ();
comp_dir = remap_debug_filename (getpwd ());
len = strlen (comp_dir) + 1;
p = frag_more (len);
memcpy (p, comp_dir, len);
/* DW_AT_producer */
- *producer_sym = symbol_temp_new_now ();
+ *producer_sym = symbol_temp_new_now_octets ();
sprintf (producer, "GNU AS %s", VERSION);
len = strlen (producer) + 1;
p = frag_more (len);