From: Matthew Malcomson Date: Mon, 7 Feb 2022 16:19:43 +0000 (+0000) Subject: Only warn on badly sized symbols X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7401203c860d95755a2cb89ffe2f1ff1f79699cc;p=thirdparty%2Fbinutils-gdb.git Only warn on badly sized symbols The reasoning behind only warning for symbols which have a size which cannot be precisely bounded is that there is nothing *requiring* precise bounds, GCC knowingly avoids changing the size of some symbols for precise bounds (TLS and symbols with user-specified alignment and user-specified section), and LLD only warns on imprecise bounds rather than erroring. N.b. the reasoning for GCC avoiding padding in these cases is explained in the commit message of b302420cb55 in the GCC branch vendors/ARM/heads/morello. All in all it's not something that we want in our toolchain as a requirement, and it's not something that other toolchains have as a requirement, so there doesn't seem to be much of a reason to include it. In order to make this warning a little nicer for anyone reading it, we add the name of the symbol to the warning. Update the testsuite to account for this. Co-Author: Alex Coplan --- diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index cd54beec7b7..939fac197d5 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -6460,6 +6460,18 @@ c64_fixup_frag (bfd *input_bfd, struct bfd_link_info *info, asection *perm_sec = sym_sec; bfd_boolean bounds_ok = FALSE; + const char *sym_name; + + if (sym) + { + Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (input_bfd); + sym_name = (bfd_elf_string_from_elf_section (input_bfd, + symtab_hdr->sh_link, + sym->st_name)); + } + else + sym_name = h->root.root.string; + if (size == 0 && sym_sec) { bounds_ok = TRUE; @@ -6492,11 +6504,13 @@ c64_fixup_frag (bfd *input_bfd, struct bfd_link_info *info, if (!bounds_ok && !c64_valid_cap_range (&base, &limit)) { + /* Just warn about this. It's not a requirement that bounds on + objects should be precise, so there's no reason to error out on + such an object. */ /* xgettext:c-format */ - _bfd_error_handler (_("%pB: capability range may exceed object bounds"), - input_bfd); - bfd_set_error (bfd_error_bad_value); - return bfd_reloc_notsupported; + _bfd_error_handler + (_("%pB: capability range for '%s' may exceed object bounds"), + input_bfd, sym_name); } if (perm_sec && perm_sec->flags & SEC_CODE) diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-5.d b/ld/testsuite/ld-aarch64/emit-relocs-morello-5.d index 05bbef145e0..7fa7909bdff 100644 --- a/ld/testsuite/ld-aarch64/emit-relocs-morello-5.d +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-5.d @@ -1,6 +1,4 @@ #source: emit-relocs-morello-5.s #as: -march=morello+c64 #ld: -static -#error: .*: capability range may exceed object bounds -#error: .*: in function `_start':.* -#error: .*: dangerous relocation: unsupported relocation +#warning: .*: capability range for 'bigarray' may exceed object bounds