[all-commits] [llvm/llvm-project] cd0143: [lld][WebAssembly] Allow data symbols to extend pa...

Sam Clegg via All-commits all-commits at lists.llvm.org
Wed May 12 13:48:46 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cd01430ff13b5441bc71e6dc3c4e688052f7be82
      https://github.com/llvm/llvm-project/commit/cd01430ff13b5441bc71e6dc3c4e688052f7be82
  Author: Sam Clegg <sbc at chromium.org>
  Date:   2021-05-12 (Wed, 12 May 2021)

  Changed paths:
    M lld/test/wasm/merge-string.s
    M llvm/lib/Object/WasmObjectFile.cpp
    A llvm/test/Object/wasm-bad-data-symbol.yaml

  Log Message:
  -----------
  [lld][WebAssembly] Allow data symbols to extend past end of segment

This fixes a bug with string merging with string symbols that contain
NULLs, as is the case in the `merge-string.s` test.

The bug only showed when we run with `--relocatable` and then try read
the resulting object back in.  In this case we would end up with string
symbols that extend past the end of the segment in which they live.

The problem comes from the fact that sections which are flagged as
string mergable assume that all strings are NULL terminated.  The
merging algorithm will drop trailing chars that follow a NULL since they
are essentially unreachable.  However, the "size" attribute (in the
symbol table) of such a truncated symbol is not updated resulting a
symbol size that can overlap the end of the segment.

I verified that this can happen in ELF too given the right conditions
and the its harmless enough.  In practice Strings that contain embedded
null should not be part of a mergable section.

Differential Revision: https://reviews.llvm.org/D102281




More information about the All-commits mailing list