[PATCH] D72197: [MC][ELF] Emit a relocation if target is defined in the same section and is non-local

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 11:45:56 PST 2020


MaskRay added a comment.

In D72197#1806495 <https://reviews.llvm.org/D72197#1806495>, @dblaikie wrote:

> I think the question I have: What is the value (I don't mean to assume there is no value, but I want to understand the specific use case) of supporting this if the full generality of symbol interposition is not supported? (is there a well defined use case that is usable with this patch and doesn't need the full generality? Or is the use case going to be subtly broken if it changes even slighlty and happens to trip over another part of LLVM that doesn't support symbol interposition? (in which case this is a great patch, but only as part of an effort to fully support the general case))


@dblaikie I came from a ppc64 use case https://reviews.llvm.org/D71639#1803561 where I could not construct a good test due to the MC issue this patch intends to fix. The advantages include at least the following:

- Improve compatibility with GNU as. This improves portability of hand-written assembly.
- Resolve a program behavior difference (-ffunction-sections vs w/o). See @peter.smith's comment above. The new behavior is consistent with the -ffunction-sections case before.
- Make MC simpler (it deleted `isWeak`)

LLVM's CMake build system uses -ffunction-sections on non-Windows-non-Darwin platforms (e.g. Linux) if CMAKE_BUILD_TYPE!=Debug. Such configurations have been thoroughly tested by various build bots and downstream users.

  # cmake/modules/HandleLLVMOptions.cmake
  if(NOT CYGWIN AND NOT WIN32)
    if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND
       NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
      check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS)
      if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
        # Don't add -ffunction-section if it can be disabled with -fno-function-sections.
        # Doing so will break sanitizers.
        add_flag_if_supported("-ffunction-sections" FFUNCTION_SECTIONS)
      endif()
      add_flag_if_supported("-fdata-sections" FDATA_SECTIONS)
    endif()
  endif()

Lack of `-fsemantic-interposition` is a larger issue that we only have a partial solution currently. Many aspects of that issue is irrelevant to this patch but I believe this patch fixes the assembler side issue any efforts on that feature will face.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72197





More information about the llvm-commits mailing list