This is a standalone repro case for golang/go#40879
testdatacontains logic to build 2 executables,badandgood.- They both have a CU DIE that uses DW_AT_ranges (to force this, I used a linker script to spread the code across 2 sections at different addresses)
badhas a.rela.debug_rangessection (it is linked with--emit-relocs)
main.gocontains logic that prints the PC ranges of a binary.test.shwill print the PC ranges using both the Go binary, andllvm-dwarfdump, to highlight the differencemakewill compile all binaries and runtest.shon bothgoodandbad, highlighting the difference.
Note: you need llvm installed (for llvm-dwarfdump). Alternatively you can change the test.sh script to use the regular dwarfdump.