@@ -671,24 +671,11 @@ RemoveNoteDetail::updateData(ArrayRef<uint8_t> OldData,
671671}
672672
673673static Error removeNote (Object &Obj, endianness Endianness,
674- ArrayRef<RemoveNoteInfo> NotesToRemove,
675- function_ref<void (const Twine &)> WarningCallback) {
676- // TODO: Support note segments.
677- for (Segment &Seg : Obj.segments ()) {
678- if (Seg.Type == PT_NOTE) {
679- WarningCallback (" note segments are not supported" );
680- break ;
681- }
682- }
674+ ArrayRef<RemoveNoteInfo> NotesToRemove) {
683675 for (auto &Sec : Obj.sections ()) {
684- if (Sec.Type != SHT_NOTE || !Sec.hasContents ())
676+ // TODO: Support note sections in segments
677+ if (Sec.Type != SHT_NOTE || Sec.ParentSegment || !Sec.hasContents ())
685678 continue ;
686- // TODO: Support note sections in segments.
687- if (Sec.ParentSegment ) {
688- WarningCallback (" cannot remove note(s) from " + Sec.Name +
689- " : sections in segments are not supported" );
690- continue ;
691- }
692679 ArrayRef<uint8_t > OldData = Sec.getContents ();
693680 size_t Align = std::max<size_t >(4 , Sec.Align );
694681 // Note: notes for both 32-bit and 64-bit ELF files use 4-byte words in the
@@ -772,8 +759,7 @@ static Error verifyNoteSection(StringRef Name, endianness Endianness,
772759// depend a) on the order the options occur in or b) on some opaque priority
773760// system. The only priority is that keeps/copies overrule removes.
774761static Error handleArgs (const CommonConfig &Config, const ELFConfig &ELFConfig,
775- ElfType OutputElfType, Object &Obj,
776- function_ref<void (const Twine &)> WarningCallback) {
762+ ElfType OutputElfType, Object &Obj) {
777763 if (Config.OutputArch ) {
778764 Obj.Machine = Config.OutputArch ->EMachine ;
779765 Obj.OSABI = Config.OutputArch ->OSABI ;
@@ -899,8 +885,7 @@ static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig,
899885 : endianness::big;
900886
901887 if (!ELFConfig.NotesToRemove .empty ()) {
902- if (Error Err =
903- removeNote (Obj, E, ELFConfig.NotesToRemove , WarningCallback))
888+ if (Error Err = removeNote (Obj, E, ELFConfig.NotesToRemove ))
904889 return Err;
905890 }
906891
@@ -1035,25 +1020,25 @@ static Error writeOutput(const CommonConfig &Config, Object &Obj,
10351020 return Writer->write ();
10361021}
10371022
1038- Error objcopy::elf::executeObjcopyOnIHex (
1039- const CommonConfig &Config, const ELFConfig &ELFConfig, MemoryBuffer &In ,
1040- raw_ostream &Out, function_ref< void ( const Twine &)> WarningCallback ) {
1023+ Error objcopy::elf::executeObjcopyOnIHex (const CommonConfig &Config,
1024+ const ELFConfig &ELFConfig,
1025+ MemoryBuffer &In, raw_ostream &Out ) {
10411026 IHexReader Reader (&In);
10421027 Expected<std::unique_ptr<Object>> Obj = Reader.create (true );
10431028 if (!Obj)
10441029 return Obj.takeError ();
10451030
10461031 const ElfType OutputElfType =
10471032 getOutputElfType (Config.OutputArch .value_or (MachineInfo ()));
1048- if (Error E =
1049- handleArgs (Config, ELFConfig, OutputElfType, **Obj, WarningCallback))
1033+ if (Error E = handleArgs (Config, ELFConfig, OutputElfType, **Obj))
10501034 return E;
10511035 return writeOutput (Config, **Obj, Out, OutputElfType);
10521036}
10531037
1054- Error objcopy::elf::executeObjcopyOnRawBinary (
1055- const CommonConfig &Config, const ELFConfig &ELFConfig, MemoryBuffer &In,
1056- raw_ostream &Out, function_ref<void (const Twine &)> WarningCallback) {
1038+ Error objcopy::elf::executeObjcopyOnRawBinary (const CommonConfig &Config,
1039+ const ELFConfig &ELFConfig,
1040+ MemoryBuffer &In,
1041+ raw_ostream &Out) {
10571042 BinaryReader Reader (&In, ELFConfig.NewSymbolVisibility );
10581043 Expected<std::unique_ptr<Object>> Obj = Reader.create (true );
10591044 if (!Obj)
@@ -1063,16 +1048,15 @@ Error objcopy::elf::executeObjcopyOnRawBinary(
10631048 // (-B<arch>).
10641049 const ElfType OutputElfType =
10651050 getOutputElfType (Config.OutputArch .value_or (MachineInfo ()));
1066- if (Error E =
1067- handleArgs (Config, ELFConfig, OutputElfType, **Obj, WarningCallback))
1051+ if (Error E = handleArgs (Config, ELFConfig, OutputElfType, **Obj))
10681052 return E;
10691053 return writeOutput (Config, **Obj, Out, OutputElfType);
10701054}
10711055
1072- Error objcopy::elf::executeObjcopyOnBinary (
1073- const CommonConfig &Config, const ELFConfig &ELFConfig,
1074- object::ELFObjectFileBase &In, raw_ostream &Out ,
1075- function_ref< void ( const Twine &)> WarningCallback ) {
1056+ Error objcopy::elf::executeObjcopyOnBinary (const CommonConfig &Config,
1057+ const ELFConfig &ELFConfig,
1058+ object::ELFObjectFileBase &In,
1059+ raw_ostream &Out ) {
10761060 ELFReader Reader (&In, Config.ExtractPartition );
10771061 Expected<std::unique_ptr<Object>> Obj =
10781062 Reader.create (!Config.SymbolsToAdd .empty ());
@@ -1083,8 +1067,7 @@ Error objcopy::elf::executeObjcopyOnBinary(
10831067 ? getOutputElfType (*Config.OutputArch )
10841068 : getOutputElfType (In);
10851069
1086- if (Error E =
1087- handleArgs (Config, ELFConfig, OutputElfType, **Obj, WarningCallback))
1070+ if (Error E = handleArgs (Config, ELFConfig, OutputElfType, **Obj))
10881071 return createFileError (Config.InputFilename , std::move (E));
10891072
10901073 if (Error E = writeOutput (Config, **Obj, Out, OutputElfType))
0 commit comments