[llvm] 'Soft Stop' solution on offset overflow issue: By Produceing a truncated but valid DWP file, discarding any DWO files that would not fit within the 32 bit/4GB limits of the format. (PR #71902)

Jinjie Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 19:34:31 PST 2023


================
@@ -720,8 +736,14 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
               C.getLength32()) {
             if (Error Err = sectionOverflowErrorOrWarning(
                     InfoSectionOffset, InfoSectionOffset + C.getLength32(),
-                    "debug_info", ContinueOnCuIndexOverflow))
+                    "debug_info", OverflowOptValue, AnySectionOverflow))
               return Err;
+            if (AnySectionOverflow) {
+              if (Header.Version < 5 ||
+                  Header.UnitType == dwarf::DW_UT_split_compile)
----------------
Labman-001 wrote:

I think the last CU is not included here because it won't be emitted after the `break` statement is executed. 
The reason for setting `FoundCUUnit = true` is primarily to prevent an overflow from occurring right at the beginning of the `debug_info` for the next CU, which is to prevent the subsequent `make_error` about header.

I believe that the last CU will not be included here because it will not be emitted once a `break` is executed. Precisely because a `break` happens here, the process of setting `FoundCUUnit` will not be entered. Therefore, setting `FoundCUUnit = true` is to prevent the subsequent `make_error` from reporting error about header, especially in the scenario of overflow occurring at the beginning of the `debug_info` for the next CU.

https://github.com/llvm/llvm-project/pull/71902


More information about the llvm-commits mailing list