/* write.c - emit .o file
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#ifdef HANDLE_ALIGN
HANDLE_ALIGN (fragP);
#endif
-skip_align:
+ skip_align:
know (fragP->fr_next != NULL);
fragP->fr_offset = (fragP->fr_next->fr_address
- fragP->fr_address
"to section %s of %s: '%s'",
(long) f->fr_fix),
(long) f->fr_fix,
- sec->name, stdoutput->filename,
+ bfd_section_name (sec), bfd_get_filename (stdoutput),
bfd_errmsg (bfd_get_error ()));
offset += f->fr_fix;
}
"in section %s of %s: '%s'",
"can't fill %ld bytes "
"in section %s of %s: '%s'",
- (long) count), (long) count,
- sec->name, stdoutput->filename,
- bfd_errmsg (bfd_get_error ()));
+ (long) count),
+ (long) count,
+ bfd_section_name (sec),
+ bfd_get_filename (stdoutput),
+ bfd_errmsg (bfd_get_error ()));
offset += count;
free (buf);
}
"in section %s of %s: '%s'",
(long) fill_size),
(long) fill_size,
- sec->name, stdoutput->filename,
+ bfd_section_name (sec),
+ bfd_get_filename (stdoutput),
bfd_errmsg (bfd_get_error ()));
offset += fill_size;
}
"in section %s of %s: '%s'",
(long) (n_per_buf * fill_size)),
(long) (n_per_buf * fill_size),
- sec->name, stdoutput->filename,
+ bfd_section_name (sec),
+ bfd_get_filename (stdoutput),
bfd_errmsg (bfd_get_error ()));
offset += n_per_buf * fill_size;
}
symbolS * sym,
bfd_size_type note_offset,
bfd_size_type desc2_offset,
+ offsetT desc2_size,
int reloc_type,
bfd_vma addend,
char * note)
but still stores the addend in the word being relocated. */
|| strstr (bfd_get_target (stdoutput), "-sh") != NULL)
{
+ offsetT i;
+
+ /* Zero out the addend, since it is now stored in the note. */
+ reloc->u.b.r.addend = 0;
+
if (target_big_endian)
{
- if (bfd_arch_bits_per_address (stdoutput) <= 32)
- note[desc2_offset + 3] = addend;
- else
- note[desc2_offset + 7] = addend;
+ for (i = desc2_size; addend != 0 && i > 0; addend >>= 8, i--)
+ note[desc2_offset + i - 1] = (addend & 0xff);
}
else
- note[desc2_offset] = addend;
+ {
+ for (i = 0; addend != 0 && i < desc2_size; addend >>= 8, i++)
+ note[desc2_offset + i] = (addend & 0xff);
+ }
}
}
if (target_big_endian)
{
note[3] = 8; /* strlen (name) + 1. */
- note[7] = desc_size; /* Two 8-byte offsets. */
+ note[7] = desc_size; /* Two N-byte offsets. */
note[10] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
note[11] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
}
else
{
note[0] = 8; /* strlen (name) + 1. */
- note[4] = desc_size; /* Two 8-byte offsets. */
+ note[4] = desc_size; /* Two N-byte offsets. */
note[8] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
note[9] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
}
memcpy (note + 12, "GA$\ 13a1", 8);
/* Create a relocation to install the start address of the note... */
- create_note_reloc (sec, sym, total_size, 20, desc_reloc, 0, note);
+ create_note_reloc (sec, sym, total_size, 20, desc_size / 2, desc_reloc, 0, note);
/* ...and another one to install the end address. */
- create_note_reloc (sec, sym, total_size, desc2_offset, desc_reloc,
+ create_note_reloc (sec, sym, total_size, desc2_offset,
+ desc_size / 2,
+ desc_reloc,
bfd_section_size (bsym->section),
note);
#endif
/* Stop if there is an error. */
- if (had_errors ())
+ if (!flag_always_generate_output && had_errors ())
return;
/* Now that all the sizes are known, and contents correct, we can
case rs_org:
{
- addressT target = offset;
+ offsetT target = offset;
addressT after;
if (symbolP)
/* Growth may be negative, but variable part of frag
cannot have fewer than 0 chars. That is, we can't
.org backwards. */
- if (address + fragP->fr_fix > target)
+ if ((offsetT) (address + fragP->fr_fix) > target)
{
growth = 0;
|| ! S_IS_DEFINED (symbolP))
{
as_bad_where (fragP->fr_file, fragP->fr_line,
- _(".space specifies non-absolute value"));
+ _(".space, .nops or .fill specifies non-absolute value"));
/* Prevent repeat of this error message. */
fragP->fr_symbol = 0;
}