@@ -33,6 +33,7 @@ constexpr char kNameString[] = "name";
3333constexpr char kSourceMappingURLString [] = " sourceMappingURL" ;
3434constexpr char kCompilationHintsString [] = " compilationHints" ;
3535constexpr char kDebugInfoString [] = " .debug_info" ;
36+ constexpr char kExternalDebugInfoString [] = " .external_debug_info" ;
3637
3738template <size_t N>
3839constexpr size_t num_chars (const char (&)[N]) {
@@ -93,6 +94,8 @@ const char* SectionName(SectionCode code) {
9394 return kSourceMappingURLString ;
9495 case kDebugInfoSectionCode :
9596 return kDebugInfoString ;
97+ case kExternalDebugInfoSectionCode :
98+ return kExternalDebugInfoString ;
9699 case kCompilationHintsSectionCode :
97100 return kCompilationHintsString ;
98101 default :
@@ -182,6 +185,11 @@ SectionCode IdentifyUnknownSectionInternal(Decoder* decoder) {
182185 strncmp (reinterpret_cast <const char *>(section_name_start),
183186 kDebugInfoString , num_chars (kDebugInfoString )) == 0 ) {
184187 return kDebugInfoSectionCode ;
188+ } else if (string.length () == num_chars (kExternalDebugInfoString ) &&
189+ strncmp (reinterpret_cast <const char *>(section_name_start),
190+ kExternalDebugInfoString ,
191+ num_chars (kExternalDebugInfoString )) == 0 ) {
192+ return kExternalDebugInfoSectionCode ;
185193 }
186194 return kUnknownSectionCode ;
187195}
@@ -452,6 +460,9 @@ class ModuleDecoderImpl : public Decoder {
452460 // .debug_info is a custom section containing core DWARF information
453461 // if produced by compiler. Its presence likely means that Wasm was
454462 // built in a debug mode.
463+ case kExternalDebugInfoSectionCode :
464+ // .external_debug_info is a custom section containing a reference to an
465+ // external symbol file.
455466 case kCompilationHintsSectionCode :
456467 // TODO(frgossen): report out of place compilation hints section as a
457468 // warning.
@@ -508,11 +519,14 @@ class ModuleDecoderImpl : public Decoder {
508519 break ;
509520 case kDebugInfoSectionCode :
510521 // If there is an explicit source map, prefer it over DWARF info.
511- if (! has_seen_unordered_section ( kSourceMappingURLSectionCode ) ) {
512- module_->source_map_url . assign ( " wasm://dwarf " ) ;
522+ if (module_-> debug_symbols . type == WasmDebugSymbols::Type::None ) {
523+ module_->debug_symbols = {WasmDebugSymbols::Type::EmbeddedDWARF, {}} ;
513524 }
514525 consume_bytes (static_cast <uint32_t >(end_ - start_), " .debug_info" );
515526 break ;
527+ case kExternalDebugInfoSectionCode :
528+ DecodeExternalDebugInfoSection ();
529+ break ;
516530 case kCompilationHintsSectionCode :
517531 if (enabled_features_.has_compilation_hints ()) {
518532 DecodeCompilationHintsSection ();
@@ -1063,12 +1077,22 @@ class ModuleDecoderImpl : public Decoder {
10631077 Decoder inner (start_, pc_, end_, buffer_offset_);
10641078 WireBytesRef url = wasm::consume_string (&inner, true , " module name" );
10651079 if (inner.ok () &&
1066- !has_seen_unordered_section (kSourceMappingURLSectionCode )) {
1067- const byte* url_start =
1068- inner.start () + inner.GetBufferRelativeOffset (url.offset ());
1069- module_->source_map_url .assign (reinterpret_cast <const char *>(url_start),
1070- url.length ());
1071- set_seen_unordered_section (kSourceMappingURLSectionCode );
1080+ module_->debug_symbols .type != WasmDebugSymbols::Type::SourceMap) {
1081+ module_->debug_symbols = {WasmDebugSymbols::Type::SourceMap, url};
1082+ }
1083+ set_seen_unordered_section (kSourceMappingURLSectionCode );
1084+ consume_bytes (static_cast <uint32_t >(end_ - start_), nullptr );
1085+ }
1086+
1087+ void DecodeExternalDebugInfoSection () {
1088+ Decoder inner (start_, pc_, end_, buffer_offset_);
1089+ WireBytesRef url =
1090+ wasm::consume_string (&inner, true , " external symbol file" );
1091+ // If there is an explicit source map, prefer it over DWARF info.
1092+ if (inner.ok () &&
1093+ module_->debug_symbols .type != WasmDebugSymbols::Type::SourceMap) {
1094+ module_->debug_symbols = {WasmDebugSymbols::Type::ExternalDWARF, url};
1095+ set_seen_unordered_section (kExternalDebugInfoSectionCode );
10721096 }
10731097 consume_bytes (static_cast <uint32_t >(end_ - start_), nullptr );
10741098 }
@@ -2157,8 +2181,8 @@ FunctionResult DecodeWasmFunctionForTesting(
21572181 const byte* function_end, Counters* counters) {
21582182 size_t size = function_end - function_start;
21592183 CHECK_LE (function_start, function_end);
2160- auto size_histogram = SELECT_WASM_COUNTER (counters, module -> origin , wasm,
2161- function_size_bytes);
2184+ auto size_histogram =
2185+ SELECT_WASM_COUNTER (counters, module -> origin , wasm, function_size_bytes);
21622186 // TODO(bradnelson): Improve histogram handling of ptrdiff_t.
21632187 size_histogram->AddSample (static_cast <int >(size));
21642188 if (size > kV8MaxWasmFunctionSize ) {
0 commit comments