Cross-Reference Overview
Cross-references (XREFs) show relationships between code and data, tracking how addresses are accessed throughout a program.Ghidra’s reference system is powered by multiple analyzers including
OperandReferenceAnalyzer and DataOperandReferenceAnalyzer.Types of References
- Code References
- Data References
- Stack References
- External References
References from instructions to addresses:
- Call: Function call instructions
- Jump: Unconditional and conditional jumps
- Callother: Special processor operations
- Computed: Indirect or calculated references
Viewing References
Reference Display in Listing
Enable XREF Field
Show references in listing:
Edit>Tool Options>Listing Fields- Enable
XReffield - Shows reference indicators
XRef Window
Open XRef Window
View all references to/from location:
- Position cursor on address
- Right-click >
References>Show References to... - Or press
Ctrl + Shift + F
Navigate References
Use the XRef panel:
- Lists all references
- Click to navigate to source
- Shows reference type
- Displays context
Creating References
Manual Reference Creation
Position Cursor
Select operand to reference:
- Click on instruction operand
- Must be a value that could be an address
Add Reference
Create the reference:
- Right-click >
References>Add/Edit References - Or press
Rkey - Opens reference editor
Configure Reference
Set reference properties:
- Target address
- Reference type (read, write, call, etc.)
- Primary/non-primary status
- Operand index
Removing References
Select Reference
Open reference editor on operand:
- Press
Ron operand with references - Shows existing references
Reference Analysis
Automatic Reference Creation
Analyzers create references automatically:- Operand References
- Data References
- Stack References
OperandReferenceAnalyzer creates:- Direct address operands
- Immediate values as addresses
- PC-relative references
- Call and jump targets
Finding Possible References
Run Analysis
Find potential references:
Analysis>Auto Analyze- Enable
Find Possible References - Implemented by
FindPossibleReferencesPlugin
Review Results
Check found references:
- Shows in results table (
FindReferencesTableModel) - Lists constants that might be addresses
- Requires manual verification
Possible reference analysis finds numeric values that fall within memory ranges, but requires manual verification to avoid false positives.
Reference Validation
Offcut References
References to middle of instructions/data:- Detected by
OffcutReferencesValidator - May indicate:
- Obfuscation
- Incorrect disassembly
- Data in code section
- Analysis errors
Review Offcut
Examine the reference:
- Check source instruction
- Verify target address
- Determine if intentional
Special Reference Types
Switch Tables
Switch statement jump tables:Identify Switch
Recognize switch pattern:
- Computed jump instruction
- Table of addresses
- Index calculation
Create References
Build switch references:
- Use
AddReferencesInSwitchTable.java - Or manually add each case
- Links switch to case blocks
Indirect References
Computed or register-based references:- Function pointer calls
- Virtual method calls
- Callback tables
- Computed jumps
Reference Propagation
Constant References
Propagate references through constants:Identify Pattern
Find constant propagation:
- Value loaded into register
- Used in later instruction
- Should create reference
Reference Navigation Workflows
Tracing Data Flow
Find Readers
Show references to data:
Ctrl + Shift + Ffor XRefs- See all code that accesses
- Identify read vs write
Tracing Control Flow
Find Callers
Show call references:
- Right-click >
References>Show Call Trees to... - See all callers
- Multi-level call hierarchy
Reference Display Options
XRef Field Configuration
Reference Hover
Quick reference preview:- Hover over reference indicator
- Shows reference details
- Click to navigate
- Implemented by hover plugins
Advanced Reference Analysis
Reference Search
Find specific reference patterns:Program Text Search
Search for references:
Search>Program Text- Can search XRef fields
- Filter by reference type
Reference Statistics
Analyze reference patterns:- Count references per function
- Find heavily-referenced data
- Identify unreferenced code
- Detect dead code
External Reference Management
Associating Symbols
Link External
Connect to external symbol:
- Use
AssociateSymbolCmd - Links internal reference to external library
- Enables signature import
External Program References
References across programs:- Shared library analysis
- Multi-binary projects
- Version comparison
- Component interaction
Proper external reference setup is crucial for accurate analysis of programs using shared libraries.
