@@ -757,12 +757,11 @@ Error RewriteInstance::run() {
757757 if (opts::Instrument && !BC->IsStaticExecutable )
758758 updateRtFiniReloc ();
759759
760- if (BC->IsLinuxKernel ) {
761- errs () << " BOLT-WARNING: not writing the output file for Linux Kernel\n " ;
762- return Error::success ();
763- } else if (opts::OutputFilename == " /dev/null" ) {
760+ if (opts::OutputFilename == " /dev/null" ) {
764761 outs () << " BOLT-INFO: skipping writing final binary to disk\n " ;
765762 return Error::success ();
763+ } else if (BC->IsLinuxKernel ) {
764+ errs () << " BOLT-WARNING: Linux kernel support is experimental\n " ;
766765 }
767766
768767 // Rewrite allocatable contents and copy non-allocatable parts with mods.
@@ -1848,6 +1847,11 @@ Error RewriteInstance::readSpecialSections() {
18481847 BC->HasRelocations =
18491848 HasTextRelocations && (opts::RelocationMode != cl::BOU_FALSE);
18501849
1850+ if (BC->IsLinuxKernel && BC->HasRelocations ) {
1851+ outs () << " BOLT-INFO: disabling relocation mode for Linux kernel\n " ;
1852+ BC->HasRelocations = false ;
1853+ }
1854+
18511855 BC->IsStripped = !HasSymbolTable;
18521856
18531857 if (BC->IsStripped && !opts::AllowStripped) {
@@ -4357,8 +4361,10 @@ void RewriteInstance::patchELFSectionHeaderTable(ELFObjectFile<ELFT> *File) {
43574361 assert ((NewEhdr.e_entry || !Obj.getHeader ().e_entry ) &&
43584362 " cannot find new address for entry point" );
43594363 }
4360- NewEhdr.e_phoff = PHDRTableOffset;
4361- NewEhdr.e_phnum = Phnum;
4364+ if (PHDRTableOffset) {
4365+ NewEhdr.e_phoff = PHDRTableOffset;
4366+ NewEhdr.e_phnum = Phnum;
4367+ }
43624368 NewEhdr.e_shoff = SHTOffset;
43634369 NewEhdr.e_shnum = OutputSections.size ();
43644370 NewEhdr.e_shstrndx = NewSectionIndex[NewEhdr.e_shstrndx ];
@@ -5493,7 +5499,8 @@ void RewriteInstance::rewriteFile() {
54935499 addBATSection ();
54945500
54955501 // Patch program header table.
5496- patchELFPHDRTable ();
5502+ if (!BC->IsLinuxKernel )
5503+ patchELFPHDRTable ();
54975504
54985505 // Finalize memory image of section string table.
54995506 finalizeSectionStringTable ();
0 commit comments