@@ -943,54 +943,60 @@ void ELFWriter::writeRelocations(const MCAssembler &Asm,
943
943
OWriter.TargetObjectWriter ->sortRelocs (Asm, Relocs);
944
944
945
945
const bool Rela = usesRela (Sec);
946
- for (const ELFRelocationEntry &Entry : Relocs) {
947
- unsigned Index = Entry.Symbol ? Entry.Symbol ->getIndex () : 0 ;
948
-
949
- if (is64Bit ()) {
950
- write (Entry.Offset );
951
- if (OWriter.TargetObjectWriter ->getEMachine () == ELF::EM_MIPS) {
952
- write (uint32_t (Index));
953
-
946
+ if (OWriter.TargetObjectWriter ->getEMachine () == ELF::EM_MIPS) {
947
+ for (const ELFRelocationEntry &Entry : Relocs) {
948
+ uint32_t Symidx = Entry.Symbol ? Entry.Symbol ->getIndex () : 0 ;
949
+ if (is64Bit ()) {
950
+ write (Entry.Offset );
951
+ write (uint32_t (Symidx));
954
952
write (OWriter.TargetObjectWriter ->getRSsym (Entry.Type ));
955
953
write (OWriter.TargetObjectWriter ->getRType3 (Entry.Type ));
956
954
write (OWriter.TargetObjectWriter ->getRType2 (Entry.Type ));
957
955
write (OWriter.TargetObjectWriter ->getRType (Entry.Type ));
956
+ if (Rela)
957
+ write (Entry.Addend );
958
958
} else {
959
- struct ELF ::Elf64_Rela ERE64;
960
- ERE64.setSymbolAndType (Index, Entry.Type );
961
- write (ERE64.r_info );
962
- }
963
- if (Rela)
964
- write (Entry.Addend );
965
- } else {
966
- write (uint32_t (Entry.Offset ));
967
-
968
- struct ELF ::Elf32_Rela ERE32;
969
- ERE32.setSymbolAndType (Index, Entry.Type );
970
- write (ERE32.r_info );
971
-
972
- if (Rela)
973
- write (uint32_t (Entry.Addend ));
974
-
975
- if (OWriter.TargetObjectWriter ->getEMachine () == ELF::EM_MIPS) {
959
+ write (uint32_t (Entry.Offset ));
960
+ ELF::Elf32_Rela ERE32;
961
+ ERE32.setSymbolAndType (Symidx, Entry.Type );
962
+ write (ERE32.r_info );
963
+ if (Rela)
964
+ write (uint32_t (Entry.Addend ));
976
965
if (uint32_t RType =
977
966
OWriter.TargetObjectWriter ->getRType2 (Entry.Type )) {
978
967
write (uint32_t (Entry.Offset ));
979
-
980
968
ERE32.setSymbolAndType (0 , RType);
981
969
write (ERE32.r_info );
982
970
write (uint32_t (0 ));
983
971
}
984
972
if (uint32_t RType =
985
973
OWriter.TargetObjectWriter ->getRType3 (Entry.Type )) {
986
974
write (uint32_t (Entry.Offset ));
987
-
988
975
ERE32.setSymbolAndType (0 , RType);
989
976
write (ERE32.r_info );
990
977
write (uint32_t (0 ));
991
978
}
992
979
}
993
980
}
981
+ return ;
982
+ }
983
+ for (const ELFRelocationEntry &Entry : Relocs) {
984
+ uint32_t Symidx = Entry.Symbol ? Entry.Symbol ->getIndex () : 0 ;
985
+ if (is64Bit ()) {
986
+ write (Entry.Offset );
987
+ ELF::Elf64_Rela ERE;
988
+ ERE.setSymbolAndType (Symidx, Entry.Type );
989
+ write (ERE.r_info );
990
+ if (Rela)
991
+ write (Entry.Addend );
992
+ } else {
993
+ write (uint32_t (Entry.Offset ));
994
+ ELF::Elf32_Rela ERE;
995
+ ERE.setSymbolAndType (Symidx, Entry.Type );
996
+ write (ERE.r_info );
997
+ if (Rela)
998
+ write (uint32_t (Entry.Addend ));
999
+ }
994
1000
}
995
1001
}
996
1002
0 commit comments