这是indexloc提供的服务,不要输入任何密码
Skip to content

Incorrect file #included #8650

@SuuperW

Description

@SuuperW

Ghidra's C preprocessor grabs the wrong file when a file of the same name exists in the include path.

To Reproduce

  1. Create a directory with the following structure:
- /a.h
- /include_a
-     foo.h
- /include_b
-     foo.h
  1. Contents of a.h: #include "include_b\foo.h"
  2. Contents of include_a/foo.h: #error this should not be included
  3. include_b/foo.h can be empty
  4. Create a parse configuration that has include_a as an include path and a.h as the sole file to parse, and no parse options. I don't think the program architecture matters, but x86:LE:64:default / gcc will reproduce this issue.
  5. Parse (either to program or to file)

Error message:

No Data Types added.

PreProcessor Messages:
...\include_a\foo.h
...\include_a\foo.h'1 #error Error: this should not be included
In file foo.h
ERROR parsing Included File: PreProcessor hit #error " this should not be included"
In file ...\a.h
PreProcessor Parse Error: PreProcessor hit #error " this should not be included"

Expected behavior
A successful parse (with no data types, since nothing was defined in the parsed file).

Attachments
bad_include.gdt_CParser.txt

Environment

  • OS: Windows 11
  • Java Version: java 21.0.5 2024-10-15 LTS
  • Ghidra Version: 11.4.2 and 11.3.1
  • Ghidra Origin: official GitHub distro

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions