[all-commits] [llvm/llvm-project] daba24: [ELF] << >>: make RHS less than 64

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jun 15 10:34:47 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: daba24ee7bd3d80f085e2e5f057af6b873a78a24
      https://github.com/llvm/llvm-project/commit/daba24ee7bd3d80f085e2e5f057af6b873a78a24
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-06-15 (Thu, 15 Jun 2023)

  Changed paths:
    M lld/ELF/ScriptParser.cpp
    M lld/test/ELF/linkerscript/operators.test

  Log Message:
  -----------
  [ELF] << >>: make RHS less than 64

The left/right shift linker script operators may trigger UB.
E.g. in linkerscript/end-overflow-check.test, the initial REGION1__PADDED_SR_SHIFT is
uint64_t(-3), cause the following expression to trigger an out-of-range shift in
a ubsan build of lld.

    REGION1__PADDED_SR_SIZE = MAX(1 << REGION1__PADDED_SR_SHIFT, 32);

Protect such UBs by making RHS less than 64.




More information about the All-commits mailing list