Skip to content

Commit fc77e9d

Browse files
authored
[yaml2obj] Apply output size limit to COFF (#209695)
Route the yaml2obj max-size setting through the COFF emitter and buffer COFF output with ContiguousBlobAccumulator. This rejects oversized YAML descriptions consistently with ELF.
1 parent 503c447 commit fc77e9d

6 files changed

Lines changed: 164 additions & 146 deletions

File tree

llvm/include/llvm/ObjectYAML/COFFYAML.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
namespace llvm {
2828

29+
namespace yaml {
30+
class ContiguousBlobAccumulator;
31+
}
32+
2933
namespace COFF {
3034

3135
inline Characteristics operator|(Characteristics a, Characteristics b) {
@@ -74,7 +78,7 @@ struct SectionDataEntry {
7478
std::optional<object::coff_load_configuration64> LoadConfig64;
7579

7680
LLVM_ABI size_t size() const;
77-
LLVM_ABI void writeAsBinary(raw_ostream &OS) const;
81+
LLVM_ABI void writeAsBinary(yaml::ContiguousBlobAccumulator &CBA) const;
7882
};
7983

8084
struct Section {

llvm/include/llvm/ObjectYAML/yaml2obj.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ using ErrorHandler = llvm::function_ref<void(const Twine &Msg)>;
7070
LLVM_ABI bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out,
7171
ErrorHandler EH);
7272
LLVM_ABI bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out,
73-
ErrorHandler EH);
73+
ErrorHandler EH, uint64_t MaxSize);
7474
LLVM_ABI bool yaml2goff(GOFFYAML::Object &Doc, raw_ostream &Out,
7575
ErrorHandler EH);
7676
LLVM_ABI bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH,

0 commit comments

Comments
 (0)