This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't emit vendor attribute section if there is no attribute need to emit.


This patch will make vendor specific attribute section won't emit if
there is no attribute.

It seems doesn't matter for emit an empty vendor specific attribute
section, but in readelf, it will cause a problem, readelf will treat
it as an corrupt file.

15571                   /* PR binutils/17531: Safe handling of corrupt
files.  */
15572                   if (attr_len < 6)
15573                     {
15574                       error (_("Unused bytes at end of section\n"));
15575                       res = FALSE;
15576                       section_len = 0;
15577                       break;
15578                     }

So here is two direction to fix this this problem, fix readelf or do
not emit attribute section if it's empty, this patch is the second
one.

This patch has 2 pre-requirement patch for the testcase[1, 2],
configure with --target=riscv32-unknown-linux-gnu or
riscv32-unknown-elf can test that.

ChangeLog:
bfd/
        * elf-attrs.c (vendor_obj_attr_size): Return 0 if size is 0 even
        for OBJ_ATTR_PROC.

gas/
        * testsuite/gas/riscv/attribute-empty.d: New.

[1] https://sourceware.org/ml/binutils/2019-01/msg00042.html
[2] https://sourceware.org/ml/binutils/2019-01/msg00041.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]