[PATCH] D73999: [MC][ELF] Error for sh_type, sh_flags or sh_entsize change

Dimitry Andric via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 11:26:16 PDT 2020


dim added a comment.

After this change, it turns out that some of the errors that this results in can be very confusing. For example, when building ocaml, it uses a .S file (https://github.com/ocaml/ocaml/blob/trunk/runtime/amd64.S#L729) containing:

  .section .rodata.cst8,"a", at progbits

Note that this is the first time in the file any such section is mentioned! Then clang 11 gives an error which appears to indicate that the flags and entsize have "changed", even though the user has no idea that these sections apparently have built-in defaults:

  amd64.S:1:1: error: changed section flags for .rodata.cst8, expected: 0x12
  .section .rodata.cst8,"a", at progbits
  ^
  amd64.S:1:1: error: changed section entsize for .rodata.cst8, expected: 8
  .section .rodata.cst8,"a", at progbits
  ^

Apparently the flags must be `"aM"`` instead, but that is hard to tell from the error message. Also, the directive does not specify an entsize at all, so how can it then complain that changed? That latter error message is not only misleading, but simply incorrect.

If you change the flags to `"aM"`, the complaint about the 'changed' flags goes away, but now you get another error about entsize:

  md64.S:1:37: error: expected the entry size
  .section .rodata.cst8,"aM", at progbits
                                      ^

So now it suddenly expects that size, while it previously fetched some internal default from somewhere?

Note that GNU as (I used 2.33.1) has much less trouble with all this:

- If you assemble the first example, e.g. `.section .rodata.cst8,"a", at progbits`, it will not warn at all.
- If you assemble the second example, e.g. `.section .rodata.cst8,"aM", at progbits`, it will warn: `amd64.S:1: Warning: entity size for SHF_MERGE not specified`. Which is much nicer, and does not break the build.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73999/new/

https://reviews.llvm.org/D73999



More information about the llvm-commits mailing list