mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-21 02:24:17 +08:00
Change objcopy's --set-section-alignment option to take a byte alignment value rather than a power of two alignment value.
PR 24942 * objcopy.c (copy_usage): Update description of --set-section-alignment. (copy_main): Interpret numeric argument of --set-section-alignment as a byte alignment, not a power of two alignment. * doc/binutils.texi: Update description of --set-section-alignment. * testsuite/binutils-all/set-section-alignment.d: New test. * testsuite/binutils-all/objcopy.exp: Run the new test.
This commit is contained in:
@ -1,3 +1,15 @@
|
|||||||
|
2019-10-02 Niklas Gürtler <profclonk@gmail.com>
|
||||||
|
|
||||||
|
PR 24942
|
||||||
|
* objcopy.c (copy_usage): Update description of
|
||||||
|
--set-section-alignment.
|
||||||
|
(copy_main): Interpret numeric argument of --set-section-alignment
|
||||||
|
as a byte alignment, not a power of two alignment.
|
||||||
|
* doc/binutils.texi: Update description of
|
||||||
|
--set-section-alignment.
|
||||||
|
* testsuite/binutils-all/set-section-alignment.d: New test.
|
||||||
|
* testsuite/binutils-all/objcopy.exp: Run the new test.
|
||||||
|
|
||||||
2019-09-30 Alan Modra <amodra@gmail.com>
|
2019-09-30 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR 25046
|
PR 25046
|
||||||
|
@ -1622,9 +1622,9 @@ contents--just remove the section instead. Not all flags are
|
|||||||
meaningful for all object file formats.
|
meaningful for all object file formats.
|
||||||
|
|
||||||
@item --set-section-alignment @var{sectionpattern}=@var{align}
|
@item --set-section-alignment @var{sectionpattern}=@var{align}
|
||||||
Set the alignment for any sections matching @var{sectionpattern}. @var{align}
|
Set the alignment for any sections matching @var{sectionpattern}.
|
||||||
specifies the alignment as the exponent for the power of two, i.e. the
|
@var{align} specifies the alignment in bytes and must be a power of
|
||||||
alignment in bytes will be 2^@var{align}.
|
two, i.e. 1, 2, 4, 8@dots{}.
|
||||||
|
|
||||||
@item --add-section @var{sectionname}=@var{filename}
|
@item --add-section @var{sectionname}=@var{filename}
|
||||||
Add a new section named @var{sectionname} while copying the file. The
|
Add a new section named @var{sectionname} while copying the file. The
|
||||||
|
@ -615,7 +615,7 @@ copy_usage (FILE *stream, int exit_status)
|
|||||||
--set-section-flags <name>=<flags>\n\
|
--set-section-flags <name>=<flags>\n\
|
||||||
Set section <name>'s properties to <flags>\n\
|
Set section <name>'s properties to <flags>\n\
|
||||||
--set-section-alignment <name>=<align>\n\
|
--set-section-alignment <name>=<align>\n\
|
||||||
Set section <name>'s alignment to 2^<align> bytes\n\
|
Set section <name>'s alignment to <align> bytes\n\
|
||||||
--add-section <name>=<file> Add section <name> found in <file> to output\n\
|
--add-section <name>=<file> Add section <name> found in <file> to output\n\
|
||||||
--update-section <name>=<file>\n\
|
--update-section <name>=<file>\n\
|
||||||
Update contents of section <name> with\n\
|
Update contents of section <name> with\n\
|
||||||
@ -5280,24 +5280,37 @@ copy_main (int argc, char *argv[])
|
|||||||
const char *s;
|
const char *s;
|
||||||
int len;
|
int len;
|
||||||
char *name;
|
char *name;
|
||||||
int align;
|
int palign, align;
|
||||||
|
|
||||||
s = strchr (optarg, '=');
|
s = strchr (optarg, '=');
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
fatal (_("bad format for %s"), "--set-section-alignment");
|
fatal (_("bad format for --set-section-alignment: argument needed"));
|
||||||
|
|
||||||
align = atoi (s + 1);
|
align = atoi (s + 1);
|
||||||
if (align < 0)
|
if (align <= 0)
|
||||||
fatal (_("bad format for %s"), "--set-section-alignment");
|
fatal (_("bad format for --set-section-alignment: numeric argument needed"));
|
||||||
|
|
||||||
|
/* Convert integer alignment into a power-of-two alignment. */
|
||||||
|
palign = 0;
|
||||||
|
while ((align & 1) == 0)
|
||||||
|
{
|
||||||
|
align >>= 1;
|
||||||
|
++palign;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (align != 1)
|
||||||
|
/* Number has more than on 1, i.e. wasn't a power of 2. */
|
||||||
|
fatal (_("bad format for --set-section-alignment: alignment is not a power of two"));
|
||||||
|
|
||||||
|
/* Add the alignment setting to the section list. */
|
||||||
len = s - optarg;
|
len = s - optarg;
|
||||||
name = (char *) xmalloc (len + 1);
|
name = (char *) xmalloc (len + 1);
|
||||||
strncpy (name, optarg, len);
|
strncpy (name, optarg, len);
|
||||||
name[len] = '\0';
|
name[len] = '\0';
|
||||||
|
|
||||||
p = find_section_list (name, TRUE, SECTION_CONTEXT_SET_ALIGNMENT);
|
p = find_section_list (name, TRUE, SECTION_CONTEXT_SET_ALIGNMENT);
|
||||||
|
if (p)
|
||||||
p->alignment = align;
|
p->alignment = palign;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1310,3 +1310,5 @@ proc objcopy_remove_relocations_from_executable { } {
|
|||||||
objcopy_remove_relocations_from_executable
|
objcopy_remove_relocations_from_executable
|
||||||
|
|
||||||
run_dump_test "pr23633"
|
run_dump_test "pr23633"
|
||||||
|
|
||||||
|
run_dump_test "set-section-alignment"
|
||||||
|
9
binutils/testsuite/binutils-all/set-section-alignment.d
Normal file
9
binutils/testsuite/binutils-all/set-section-alignment.d
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#source: pr23633.s
|
||||||
|
#PROG: objcopy
|
||||||
|
#objcopy: --set-section-alignment .text=16
|
||||||
|
#objdump: --section-headers
|
||||||
|
#notarget: *-*-*aout *-*-*coff *-*-cygwin* *-*-darwin *-*-mingw* *-*-go32 *-*-*pe hppa*-*-hpux* ns32k-*-* powerpc-*-aix* rs6000-*-* rx-*-* *-*-vms
|
||||||
|
|
||||||
|
#...
|
||||||
|
.*\.text.*2\*\*4
|
||||||
|
#pass
|
Reference in New Issue
Block a user