capstone-engine / capstone

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
http://www.capstone-engine.org
7.62k stars 1.56k forks source link

Compiler warnings in the next branch #2340

Open trufae opened 7 months ago

trufae commented 7 months ago

Using gcc11.4 on linux-ppc

$ make -j3
  CC      cs.o
  CC      SStream.o
  CC      utils.o
  CC      MCInstrDesc.o
  CC      MCRegisterInfo.o
  CC      MCInst.o
  CC      MCInstPrinter.o
  CC      Mapping.o
  CC      arch/ARM/ARMBaseInfo.o
  CC      arch/ARM/ARMDisassembler.o
  CC      arch/ARM/ARMDisassemblerExtension.o
  CC      arch/ARM/ARMInstPrinter.o
In file included from arch/ARM/ARMInstPrinter.c:66:
arch/ARM/ARMGenAsmWriter.inc:9626:6: warning: no previous prototype for ‘printInstruction’ [-Wmissing-prototypes]
 9626 | void printInstruction(MCInst *MI, uint64_t Address, SStream *O)
      |      ^~~~~~~~~~~~~~~~
arch/ARM/ARMGenAsmWriter.inc:12436:13: warning: no previous prototype for ‘getRegisterName’ [-Wmissing-prototypes]
12436 | const char *getRegisterName(unsigned RegNo, unsigned AltIdx)
      |             ^~~~~~~~~~~~~~~
  CC      arch/ARM/ARMMapping.o
  CC      arch/ARM/ARMModule.o
  CC      arch/AArch64/AArch64BaseInfo.o
  CC      arch/AArch64/AArch64Disassembler.o
  CC      arch/AArch64/AArch64DisassemblerExtension.o
arch/AArch64/AArch64Disassembler.c:411:10: warning: no previous prototype for ‘suggestBytesToSkip’ [-Wmissing-prototypes]
  411 | uint64_t suggestBytesToSkip(const uint8_t *Bytes, uint64_t Address)
      |          ^~~~~~~~~~~~~~~~~~
  CC      arch/AArch64/AArch64InstPrinter.o
arch/AArch64/AArch64InstPrinter.c:911:6: warning: no previous prototype for ‘AArch64AppleInstPrinter_printInst’ [-Wmissing-prototypes]
  911 | void AArch64AppleInstPrinter_printInst(MCInst *MI, uint64_t Address, const char *Annot, SStream *O)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CC      arch/AArch64/AArch64Mapping.o
arch/AArch64/AArch64Mapping.c:226:6: warning: no previous prototype for ‘AArch64_setup_op’ [-Wmissing-prototypes]
  226 | void AArch64_setup_op(cs_aarch64_op *op)
      |      ^~~~~~~~~~~~~~~~
arch/AArch64/AArch64Mapping.c:615:14: warning: no previous prototype for ‘AArch64_map_insn’ [-Wmissing-prototypes]
  615 | aarch64_insn AArch64_map_insn(const char *name)
      |              ^~~~~~~~~~~~~~~~
arch/AArch64/AArch64Mapping.c:869:6: warning: no previous prototype for ‘AArch64_set_mem_access’ [-Wmissing-prototypes]
  869 | void AArch64_set_mem_access(MCInst *MI, bool status)
      |      ^~~~~~~~~~~~~~~~~~~~~~
  CC      arch/AArch64/AArch64Module.o
  CC      arch/M68K/M68KDisassembler.o
  CC      arch/M68K/M68KInstPrinter.o
  CC      arch/M68K/M68KModule.o
  CC      arch/Mips/MipsDisassembler.o
  CC      arch/Mips/MipsInstPrinter.o
  CC      arch/Mips/MipsMapping.o
  CC      arch/Mips/MipsModule.o
  CC      arch/PowerPC/PPCDisassembler.o
arch/PowerPC/PPCDisassembler.c:210:14: warning: no previous prototype for ‘DecodeDMRROWRCRegisterClass’ [-Wmissing-prototypes]
  210 | DecodeStatus DecodeDMRROWRCRegisterClass(MCInst *Inst, uint64_t RegNo,
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/PowerPC/PPCDisassembler.c:232:14: warning: no previous prototype for ‘DecodeDMRpRCRegisterClass’ [-Wmissing-prototypes]
  232 | DecodeStatus DecodeDMRpRCRegisterClass(MCInst *Inst, uint64_t RegNo,
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~
  CC      arch/PowerPC/PPCInstPrinter.o
arch/PowerPC/PPCInstPrinter.c:686:13: warning: no previous prototype for ‘getVerboseConditionRegName’ [-Wmissing-prototypes]
  686 | const char *getVerboseConditionRegName(const MCInst *MI, unsigned RegNum,
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
  CC      arch/PowerPC/PPCMapping.o
  CC      arch/PowerPC/PPCModule.o
  CC      arch/RISCV/RISCVDisassembler.o
  CC      arch/RISCV/RISCVInstPrinter.o
  CC      arch/RISCV/RISCVMapping.o
  CC      arch/RISCV/RISCVModule.o
  CC      arch/Sparc/SparcDisassembler.o
  CC      arch/Sparc/SparcInstPrinter.o
  CC      arch/Sparc/SparcMapping.o
  CC      arch/Sparc/SparcModule.o
  CC      arch/SystemZ/SystemZDisassembler.o
  CC      arch/SystemZ/SystemZInstPrinter.o
  CC      arch/SystemZ/SystemZMCTargetDesc.o
  CC      arch/SystemZ/SystemZMapping.o
  CC      arch/SystemZ/SystemZModule.o
  CC      arch/SH/SHDisassembler.o
  CC      arch/SH/SHInstPrinter.o
  CC      arch/SH/SHModule.o
  CC      arch/X86/X86DisassemblerDecoder.o
  CC      arch/X86/X86Disassembler.o
  CC      arch/X86/X86InstPrinterCommon.o
  CC      arch/X86/X86IntelInstPrinter.o
  CC      arch/X86/X86ATTInstPrinter.o
  CC      arch/X86/X86Mapping.o
  CC      arch/X86/X86Module.o
  CC      arch/XCore/XCoreDisassembler.o
  CC      arch/XCore/XCoreInstPrinter.o
  CC      arch/XCore/XCoreMapping.o
  CC      arch/XCore/XCoreModule.o
  CC      arch/TMS320C64x/TMS320C64xDisassembler.o
  CC      arch/TMS320C64x/TMS320C64xInstPrinter.o
  CC      arch/TMS320C64x/TMS320C64xMapping.o
  CC      arch/TMS320C64x/TMS320C64xModule.o
  CC      arch/M680X/M680XDisassembler.o
  CC      arch/M680X/M680XInstPrinter.o
  CC      arch/M680X/M680XModule.o
  CC      arch/EVM/EVMDisassembler.o
  CC      arch/EVM/EVMInstPrinter.o
  CC      arch/EVM/EVMMapping.o
  CC      arch/EVM/EVMModule.o
  CC      arch/MOS65XX/MOS65XXDisassembler.o
  CC      arch/MOS65XX/MOS65XXModule.o
  CC      arch/WASM/WASMDisassembler.o
  CC      arch/WASM/WASMInstPrinter.o
  CC      arch/WASM/WASMMapping.o
  CC      arch/WASM/WASMModule.o
  CC      arch/BPF/BPFDisassembler.o
  CC      arch/BPF/BPFInstPrinter.o
  CC      arch/BPF/BPFMapping.o
  CC      arch/BPF/BPFModule.o
  CC      arch/TriCore/TriCoreDisassembler.o
  CC      arch/TriCore/TriCoreInstPrinter.o
  CC      arch/TriCore/TriCoreMapping.o
  CC      arch/TriCore/TriCoreModule.o
  CC      arch/Alpha/AlphaDisassembler.o
In file included from arch/Alpha/AlphaDisassembler.c:30:
arch/Alpha/AlphaDisassembler.c: In function ‘Alpha_LLVM_getInstruction’:
arch/Alpha/AlphaGenDisassemblerTables.inc:1026:10: warning: ‘DecodeComplete’ may be used uninitialized [-Wmaybe-uninitialized]
 1026 |       if (DecodeComplete) { \
      |          ^
arch/Alpha/AlphaGenDisassemblerTables.inc:1024:12: note: ‘DecodeComplete’ was declared here
 1024 |       bool DecodeComplete; \
      |            ^~~~~~~~~~~~~~
arch/Alpha/AlphaGenDisassemblerTables.inc:1060:1: note: in expansion of macro ‘DecodeInstruction’
 1060 | DecodeInstruction(decodeInstruction_4, fieldFromInstruction_4, decodeToMCInst_4, uint32_t)
      | ^~~~~~~~~~~~~~~~~
  CC      arch/Alpha/AlphaInstPrinter.o
  CC      arch/Alpha/AlphaMapping.o
  CC      arch/Alpha/AlphaModule.o
  CC      arch/HPPA/HPPADisassembler.o
  CC      arch/HPPA/HPPAInstPrinter.o
arch/HPPA/HPPADisassembler.c:3815:6: warning: no previous prototype for ‘init_details’ [-Wmissing-prototypes]
 3815 | void init_details(MCInst *MI)
      |      ^~~~~~~~~~~~
  CC      arch/HPPA/HPPAMapping.o
trufae commented 7 months ago

gcc13 reports this message ad infinitum (as well as many other warnings)

In function 'get_op_access',
    inlined from 'printOperand' at arch/X86/X86ATTInstPrinter.c:575:5:
arch/X86/X86ATTInstPrinter.c:307:35: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
  307 |                         access[i] = arr[count - i];
      |                         ~~~~~~~~~~^~~~~~~~~~~~~~~~
arch/X86/X86ATTInstPrinter.c: In function 'printOperand':
arch/X86/X86ATTInstPrinter.c:569:41: note: at offset 128 into destination object 'access' of size 6
  569 |                                 uint8_t access[CS_X86_MAXIMUM_OPERAND_SIZE];
      |                                         ^~~~~~
In function 'get_op_access',
    inlined from 'printOperand' at arch/X86/X86ATTInstPrinter.c:575:5:
arch/X86/X86ATTInstPrinter.c:307:35: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
  307 |                         access[i] = arr[count - i];
      |                         ~~~~~~~~~~^~~~~~~~~~~~~~~~
Rot127 commented 6 months ago

The -Wmaybe-uninitialized is giving us false positive on some LLVM code. This is why we have disabled it. The others are of course valid. Will add the over the next weeks.

Rot127 commented 2 months ago

Moved this to the v6 - Beta milestone. The important ones are fixed in https://github.com/capstone-engine/capstone/pull/2469. The rest should be only the missing-prototype.

With the v6 Beta the PPC and ARM update to LLVM-18 will come. And the Auto-Sync process will be more streamlined and be reproducible. Then we can fix those.