mirror of
https://github.com/zeldaret/oot.git
synced 2025-06-07 17:11:50 +00:00
Finish matching ique-cn (#2451)
* git subrepo clone git@github.com:Thar0/com-plugin.git tools/com-plugin subrepo: subdir: "tools/com-plugin" merged: "e8543312d" upstream: origin: "git@github.com:Thar0/com-plugin.git" branch: "main" commit: "e8543312d" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb" * ique-cn OK * Review suggestions * Most suggestions * git subrepo pull tools/com-plugin subrepo: subdir: "tools/com-plugin" merged: "81595ed1c" upstream: origin: "git@github.com:Thar0/com-plugin.git" branch: "main" commit: "81595ed1c" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb" * Fix other versions
This commit is contained in:
parent
6c06168e72
commit
c028db03b4
51 changed files with 5756 additions and 52 deletions
7
Jenkinsfile
vendored
7
Jenkinsfile
vendored
|
@ -120,6 +120,13 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Build ique-cn') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
build('ique-cn', 'oot-ique-cn.z64')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Generate patch') {
|
stage('Generate patch') {
|
||||||
when {
|
when {
|
||||||
not {
|
not {
|
||||||
|
|
22
Makefile
22
Makefile
|
@ -36,6 +36,7 @@ COMPILER ?= ido
|
||||||
# gc-eu GameCube Europe/PAL
|
# gc-eu GameCube Europe/PAL
|
||||||
# gc-eu-mq GameCube Europe/PAL Master Quest
|
# gc-eu-mq GameCube Europe/PAL Master Quest
|
||||||
# gc-jp-ce GameCube Japan (Collector's Edition disc)
|
# gc-jp-ce GameCube Japan (Collector's Edition disc)
|
||||||
|
# ique-cn iQue Player (Simplified Chinese)
|
||||||
VERSION ?= gc-eu-mq-dbg
|
VERSION ?= gc-eu-mq-dbg
|
||||||
# Number of threads to extract and compress with.
|
# Number of threads to extract and compress with.
|
||||||
N_THREADS ?= $(shell nproc)
|
N_THREADS ?= $(shell nproc)
|
||||||
|
@ -167,7 +168,6 @@ else ifeq ($(VERSION),gc-jp-ce)
|
||||||
BUILD_TIME := 21:53:00
|
BUILD_TIME := 21:53:00
|
||||||
REVISION := 15
|
REVISION := 15
|
||||||
else ifeq ($(VERSION),ique-cn)
|
else ifeq ($(VERSION),ique-cn)
|
||||||
COMPARE := 0
|
|
||||||
REGION ?= US
|
REGION ?= US
|
||||||
PLATFORM := IQUE
|
PLATFORM := IQUE
|
||||||
DEBUG_FEATURES ?= 0
|
DEBUG_FEATURES ?= 0
|
||||||
|
@ -603,6 +603,7 @@ $(BUILD_DIR)/src/libc/%.o: CFLAGS := $(EGCS_CFLAGS) -mno-abicalls
|
||||||
$(BUILD_DIR)/src/libc/%.o: CCASFLAGS := $(EGCS_CCASFLAGS)
|
$(BUILD_DIR)/src/libc/%.o: CCASFLAGS := $(EGCS_CCASFLAGS)
|
||||||
$(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -O1
|
$(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -O1
|
||||||
$(BUILD_DIR)/src/libc/%.o: MIPS_VERSION :=
|
$(BUILD_DIR)/src/libc/%.o: MIPS_VERSION :=
|
||||||
|
$(BUILD_DIR)/src/libc/memmove.o: MIPS_VERSION := -mips2
|
||||||
else ifeq ($(DEBUG_FEATURES),1)
|
else ifeq ($(DEBUG_FEATURES),1)
|
||||||
$(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -g
|
$(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -g
|
||||||
$(BUILD_DIR)/src/libc/%.o: ASOPTFLAGS := -g
|
$(BUILD_DIR)/src/libc/%.o: ASOPTFLAGS := -g
|
||||||
|
@ -825,10 +826,18 @@ $(ROMC): $(ROM) $(ELF) $(BUILD_DIR)/compress_ranges.txt
|
||||||
$(PYTHON) tools/compress.py --in $(ROM) --out $@ --dmadata-start `./tools/dmadata_start.sh $(NM) $(ELF)` --compress `cat $(BUILD_DIR)/compress_ranges.txt` --threads $(N_THREADS) $(COMPRESS_ARGS)
|
$(PYTHON) tools/compress.py --in $(ROM) --out $@ --dmadata-start `./tools/dmadata_start.sh $(NM) $(ELF)` --compress `cat $(BUILD_DIR)/compress_ranges.txt` --threads $(N_THREADS) $(COMPRESS_ARGS)
|
||||||
$(PYTHON) -m ipl3checksum sum --cic $(CIC) --update $@
|
$(PYTHON) -m ipl3checksum sum --cic $(CIC) --update $@
|
||||||
|
|
||||||
|
COM_PLUGIN := tools/com-plugin/common-plugin.so
|
||||||
|
|
||||||
|
LDFLAGS := -T $(LDSCRIPT) -T $(BUILD_DIR)/linker_scripts/makerom.ld -T $(BUILD_DIR)/undefined_syms.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map $(MAP)
|
||||||
|
ifeq ($(PLATFORM),IQUE)
|
||||||
|
LDFLAGS += -plugin $(COM_PLUGIN) -plugin-opt order=$(BASEROM_DIR)/bss-order.txt
|
||||||
|
$(ELF): $(BASEROM_DIR)/bss-order.txt
|
||||||
|
endif
|
||||||
|
|
||||||
$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) $(LDSCRIPT) $(BUILD_DIR)/linker_scripts/makerom.ld $(BUILD_DIR)/undefined_syms.txt \
|
$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) $(LDSCRIPT) $(BUILD_DIR)/linker_scripts/makerom.ld $(BUILD_DIR)/undefined_syms.txt \
|
||||||
$(SAMPLEBANK_O_FILES) $(SOUNDFONT_O_FILES) $(SEQUENCE_O_FILES) \
|
$(SAMPLEBANK_O_FILES) $(SOUNDFONT_O_FILES) $(SEQUENCE_O_FILES) \
|
||||||
$(BUILD_DIR)/assets/audio/sequence_font_table.o $(BUILD_DIR)/assets/audio/audiobank_padding.o
|
$(BUILD_DIR)/assets/audio/sequence_font_table.o $(BUILD_DIR)/assets/audio/audiobank_padding.o
|
||||||
$(LD) -T $(LDSCRIPT) -T $(BUILD_DIR)/linker_scripts/makerom.ld -T $(BUILD_DIR)/undefined_syms.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map $(MAP) -o $@
|
$(LD) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/linker_scripts/makerom.ld: linker_scripts/makerom.ld
|
$(BUILD_DIR)/linker_scripts/makerom.ld: linker_scripts/makerom.ld
|
||||||
$(CPP) -I include $(CPPFLAGS) $< > $@
|
$(CPP) -I include $(CPPFLAGS) $< > $@
|
||||||
|
@ -927,7 +936,7 @@ endif
|
||||||
|
|
||||||
# Incremental link to move z_message and z_game_over data into rodata
|
# Incremental link to move z_message and z_game_over data into rodata
|
||||||
$(BUILD_DIR)/src/code/z_message_z_game_over.o: $(BUILD_DIR)/src/code/z_message.o $(BUILD_DIR)/src/code/z_game_over.o
|
$(BUILD_DIR)/src/code/z_message_z_game_over.o: $(BUILD_DIR)/src/code/z_message.o $(BUILD_DIR)/src/code/z_game_over.o
|
||||||
$(LD) -r -T linker_scripts/data_with_rodata.ld -o $@ $^
|
$(LD) -r -G 0 -T linker_scripts/data_with_rodata.ld -o $@ $^
|
||||||
|
|
||||||
$(BUILD_DIR)/dmadata_table_spec.h $(BUILD_DIR)/compress_ranges.txt: $(BUILD_DIR)/spec
|
$(BUILD_DIR)/dmadata_table_spec.h $(BUILD_DIR)/compress_ranges.txt: $(BUILD_DIR)/spec
|
||||||
$(MKDMADATA) $< $(BUILD_DIR)/dmadata_table_spec.h $(BUILD_DIR)/compress_ranges.txt
|
$(MKDMADATA) $< $(BUILD_DIR)/dmadata_table_spec.h $(BUILD_DIR)/compress_ranges.txt
|
||||||
|
@ -964,8 +973,15 @@ endif
|
||||||
$(LD) -r -T linker_scripts/data_with_rodata.ld -o $@ $(@:.o=.tmp)
|
$(LD) -r -T linker_scripts/data_with_rodata.ld -o $@ $(@:.o=.tmp)
|
||||||
@$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s)
|
@$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s)
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM),IQUE)
|
||||||
|
ifneq ($(NON_MATCHING),1)
|
||||||
|
$(BUILD_DIR)/src/overlays/misc/ovl_kaleido_scope/ovl_kaleido_scope_reloc.o: POSTPROCESS_OBJ := $(PYTHON) tools/patch_ique_kaleido_reloc.py
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
$(BUILD_DIR)/src/overlays/%_reloc.o: $(BUILD_DIR)/spec
|
$(BUILD_DIR)/src/overlays/%_reloc.o: $(BUILD_DIR)/spec
|
||||||
$(FADO) $$(tools/reloc_prereq $< $(notdir $*)) -n $(notdir $*) -o $(@:.o=.s) -M $(@:.o=.d)
|
$(FADO) $$(tools/reloc_prereq $< $(notdir $*)) -n $(notdir $*) -o $(@:.o=.s) -M $(@:.o=.d)
|
||||||
|
$(POSTPROCESS_OBJ) $(@:.o=.s)
|
||||||
$(AS) $(ASFLAGS) $(@:.o=.s) -o $@
|
$(AS) $(ASFLAGS) $(@:.o=.s) -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/assets/%.inc.c: assets/%.png
|
$(BUILD_DIR)/assets/%.inc.c: assets/%.png
|
||||||
|
|
|
@ -42,6 +42,7 @@ It builds the following versions:
|
||||||
| gc-eu | 03-02-21 20:12:23 | GameCube Europe/PAL | `2c27b4e000e85fd78dbca551f1b1c965` |
|
| gc-eu | 03-02-21 20:12:23 | GameCube Europe/PAL | `2c27b4e000e85fd78dbca551f1b1c965` |
|
||||||
| gc-eu-mq | 03-02-21 20:37:19 | GameCube Europe/PAL Master Quest | `1618403427e4344a57833043db5ce3c3` |
|
| gc-eu-mq | 03-02-21 20:37:19 | GameCube Europe/PAL Master Quest | `1618403427e4344a57833043db5ce3c3` |
|
||||||
| gc-jp-ce | 03-10-08 21:53:00 | GameCube Japan (Collector's Edition Disc) | `0c13e0449a28ea5b925cdb8af8d29768` |
|
| gc-jp-ce | 03-10-08 21:53:00 | GameCube Japan (Collector's Edition Disc) | `0c13e0449a28ea5b925cdb8af8d29768` |
|
||||||
|
| ique-cn | 03-10-22 16:23:19 | iQue Player (Simplified Chinese) | `0ab48b2d44a74b3bb2d384f6170c2742` |
|
||||||
|
|
||||||
The default version is `gc-eu-mq-dbg`, i.e. the GameCube Europe/PAL Master Quest Debug ROM.
|
The default version is `gc-eu-mq-dbg`, i.e. the GameCube Europe/PAL Master Quest Debug ROM.
|
||||||
|
|
||||||
|
|
60
assets/xml/textures/parameter_static_ique.xml
Normal file
60
assets/xml/textures/parameter_static_ique.xml
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<Root>
|
||||||
|
<File Name="parameter_static" Segment="2">
|
||||||
|
<Texture Name="gHeartEmptyTex" OutName="heart_empty" Format="ia8" Width="16" Height="16" Offset="0x0"/>
|
||||||
|
<Texture Name="gHeartQuarterTex" OutName="heart_quarter" Format="ia8" Width="16" Height="16" Offset="0x100"/>
|
||||||
|
<Texture Name="gHeartHalfTex" OutName="heart_half" Format="ia8" Width="16" Height="16" Offset="0x200"/>
|
||||||
|
<Texture Name="gHeartThreeQuarterTex" OutName="heart_three_quarter" Format="ia8" Width="16" Height="16" Offset="0x300"/>
|
||||||
|
<Texture Name="gHeartFullTex" OutName="heart_full" Format="ia8" Width="16" Height="16" Offset="0x400"/>
|
||||||
|
<Texture Name="gDefenseHeartEmptyTex" OutName="defense_heart_empty" Format="ia8" Width="16" Height="16" Offset="0x500"/>
|
||||||
|
<Texture Name="gDefenseHeartQuarterTex" OutName="defense_heart_quarter" Format="ia8" Width="16" Height="16" Offset="0x600"/>
|
||||||
|
<Texture Name="gDefenseHeartHalfTex" OutName="defense_heart_half" Format="ia8" Width="16" Height="16" Offset="0x700"/>
|
||||||
|
<Texture Name="gDefenseHeartThreeQuarterTex" OutName="defense_heart_three_quarter" Format="ia8" Width="16" Height="16" Offset="0x800"/>
|
||||||
|
<Texture Name="gDefenseHeartFullTex" OutName="defense_heart_full" Format="ia8" Width="16" Height="16" Offset="0x900"/>
|
||||||
|
<Texture Name="gButtonBackgroundTex" OutName="button_background" Format="ia8" Width="32" Height="32" Offset="0xA00"/>
|
||||||
|
<Texture Name="gEquippedItemOutlineTex" OutName="equipped_item_outline" Format="ia8" Width="32" Height="32" Offset="0xE00"/>
|
||||||
|
<Texture Name="gEmptyCLeftArrowTex" OutName="empty_c_left_arrow" Format="ia8" Width="32" Height="32" Offset="0x1200"/>
|
||||||
|
<Texture Name="gEmptyCDownArrowTex" OutName="empty_c_down_arrow" Format="ia8" Width="32" Height="32" Offset="0x1600"/>
|
||||||
|
<Texture Name="gEmptyCRightArrowTex" OutName="empty_c_right_arrow" Format="ia8" Width="32" Height="32" Offset="0x1A00"/>
|
||||||
|
<Texture Name="gSmallKeyCounterIconTex" OutName="small_key_counter_icon" Format="ia8" Width="16" Height="16" Offset="0x1E00"/>
|
||||||
|
<Texture Name="gRupeeCounterIconTex" OutName="rupee_counter_icon" Format="ia8" Width="16" Height="16" Offset="0x1F00"/>
|
||||||
|
<Texture Name="gClockIconTex" OutName="clock_icon" Format="ia8" Width="16" Height="16" Offset="0x2000"/>
|
||||||
|
<Texture Name="gCarrotIconTex" OutName="carrot_icon" Format="rgba32" Width="16" Height="16" Offset="0x2100"/>
|
||||||
|
<Texture Name="gMapDungeonEntranceIconTex" OutName="map_dungeon_entrance_icon" Format="rgba16" Width="8" Height="8" Offset="0x2500"/>
|
||||||
|
<Texture Name="gMapChestIconTex" OutName="map_chest_icon" Format="rgba16" Width="8" Height="8" Offset="0x2580"/>
|
||||||
|
<Texture Name="gArcheryScoreIconTex" OutName="archery_score_icon" Format="rgba16" Width="24" Height="16" Offset="0x2600"/>
|
||||||
|
<Texture Name="gMapBossIconTex" OutName="map_boss_icon" Format="ia8" Width="8" Height="8" Offset="0x2900"/>
|
||||||
|
<Texture Name="gOcarinaBtnIconATex" OutName="ocarina_a" Format="ia8" Width="16" Height="16" Offset="0x2940"/>
|
||||||
|
<Texture Name="gOcarinaBtnIconCDownTex" OutName="ocarina_c_down" Format="ia8" Width="16" Height="16" Offset="0x2A40"/>
|
||||||
|
<Texture Name="gOcarinaBtnIconCRightTex" OutName="ocarina_c_right" Format="ia8" Width="16" Height="16" Offset="0x2B40"/>
|
||||||
|
<Texture Name="gOcarinaBtnIconCLeftTex" OutName="ocarina_c_left" Format="ia8" Width="16" Height="16" Offset="0x2C40"/>
|
||||||
|
<Texture Name="gOcarinaBtnIconCUpTex" OutName="ocarina_c_up" Format="ia8" Width="16" Height="16" Offset="0x2D40"/>
|
||||||
|
<Texture Name="gOcarinaTrebleClefTex" OutName="ocarina_treble_clef" Format="i4" Width="16" Height="32" Offset="0x2E40"/>
|
||||||
|
<Texture Name="gNaviCUpJPNTex" OutName="navi_c_up_jpn" Format="ia4" Width="32" Height="8" Offset="0x2F40"/>
|
||||||
|
<Texture Name="gNaviCUpENGTex" OutName="navi_c_up_eng" Format="ia4" Width="32" Height="8" Offset="0x2FC0"/>
|
||||||
|
<Texture Name="gCounterDigit0Tex" OutName="counter_digit_0" Format="i8" Width="8" Height="16" Offset="0x3140"/>
|
||||||
|
<Texture Name="gCounterDigit1Tex" OutName="counter_digit_1" Format="i8" Width="8" Height="16" Offset="0x31C0"/>
|
||||||
|
<Texture Name="gCounterDigit2Tex" OutName="counter_digit_2" Format="i8" Width="8" Height="16" Offset="0x3240"/>
|
||||||
|
<Texture Name="gCounterDigit3Tex" OutName="counter_digit_3" Format="i8" Width="8" Height="16" Offset="0x32C0"/>
|
||||||
|
<Texture Name="gCounterDigit4Tex" OutName="counter_digit_4" Format="i8" Width="8" Height="16" Offset="0x3340"/>
|
||||||
|
<Texture Name="gCounterDigit5Tex" OutName="counter_digit_5" Format="i8" Width="8" Height="16" Offset="0x33C0"/>
|
||||||
|
<Texture Name="gCounterDigit6Tex" OutName="counter_digit_6" Format="i8" Width="8" Height="16" Offset="0x3440"/>
|
||||||
|
<Texture Name="gCounterDigit7Tex" OutName="counter_digit_7" Format="i8" Width="8" Height="16" Offset="0x34C0"/>
|
||||||
|
<Texture Name="gCounterDigit8Tex" OutName="counter_digit_8" Format="i8" Width="8" Height="16" Offset="0x3540"/>
|
||||||
|
<Texture Name="gCounterDigit9Tex" OutName="counter_digit_9" Format="i8" Width="8" Height="16" Offset="0x35C0"/>
|
||||||
|
<Texture Name="gCounterColonTex" OutName="counter_colon" Format="i8" Width="8" Height="16" Offset="0x3640"/>
|
||||||
|
<Texture Name="gAmmoDigit0Tex" OutName="ammo_digit_0" Format="ia8" Width="8" Height="8" Offset="0x36C0"/>
|
||||||
|
<Texture Name="gAmmoDigit1Tex" OutName="ammo_digit_1" Format="ia8" Width="8" Height="8" Offset="0x3700"/>
|
||||||
|
<Texture Name="gAmmoDigit2Tex" OutName="ammo_digit_2" Format="ia8" Width="8" Height="8" Offset="0x3740"/>
|
||||||
|
<Texture Name="gAmmoDigit3Tex" OutName="ammo_digit_3" Format="ia8" Width="8" Height="8" Offset="0x3780"/>
|
||||||
|
<Texture Name="gAmmoDigit4Tex" OutName="ammo_digit_4" Format="ia8" Width="8" Height="8" Offset="0x37C0"/>
|
||||||
|
<Texture Name="gAmmoDigit5Tex" OutName="ammo_digit_5" Format="ia8" Width="8" Height="8" Offset="0x3800"/>
|
||||||
|
<Texture Name="gAmmoDigit6Tex" OutName="ammo_digit_6" Format="ia8" Width="8" Height="8" Offset="0x3840"/>
|
||||||
|
<Texture Name="gAmmoDigit7Tex" OutName="ammo_digit_7" Format="ia8" Width="8" Height="8" Offset="0x3880"/>
|
||||||
|
<Texture Name="gAmmoDigit8Tex" OutName="ammo_digit_8" Format="ia8" Width="8" Height="8" Offset="0x38C0"/>
|
||||||
|
<Texture Name="gAmmoDigit9Tex" OutName="ammo_digit_9" Format="ia8" Width="8" Height="8" Offset="0x3900"/>
|
||||||
|
<Texture Name="gUnusedAmmoDigitHalfTex" OutName="unused_ammo_digit_half" Format="ia8" Width="16" Height="8" Offset="0x3940"/>
|
||||||
|
<Texture Name="gMagicMeterEndTex" OutName="magic_meter_end" Format="ia8" Width="8" Height="16" Offset="0x39C0"/>
|
||||||
|
<Texture Name="gMagicMeterMidTex" OutName="magic_meter_mid" Format="ia8" Width="24" Height="16" Offset="0x3A40"/>
|
||||||
|
<Texture Name="gMagicMeterFillTex" OutName="magic_meter_fill" Format="ia8" Width="8" Height="8" Offset="0x3BC0"/>
|
||||||
|
</File>
|
||||||
|
</Root>
|
110
baseroms/ique-cn/bss-order.txt
Normal file
110
baseroms/ique-cn/bss-order.txt
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
// Specification for linker plugin COMMON symbol order for the ique-cn version
|
||||||
|
|
||||||
|
build/ique-cn/boot_bss_1.o {
|
||||||
|
bk;
|
||||||
|
__osBaseCounter;
|
||||||
|
__osBbRCountWraps;
|
||||||
|
__osBbLastRCount;
|
||||||
|
__osViIntrCount;
|
||||||
|
insize;
|
||||||
|
outcnt;
|
||||||
|
bb;
|
||||||
|
__osCurrentTime;
|
||||||
|
hufts;
|
||||||
|
__osBbLastVCount;
|
||||||
|
__osTimerCounter;
|
||||||
|
__osBbVCountWraps;
|
||||||
|
__osFinalrom;
|
||||||
|
inptr;
|
||||||
|
ifd;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/boot_bss_boot_main.o {
|
||||||
|
sBootThreadInfo;
|
||||||
|
sIdleThread;
|
||||||
|
sIdleThreadStack;
|
||||||
|
sIdleThreadInfo;
|
||||||
|
sBootThreadStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/boot_bss_idle.o {
|
||||||
|
sMainThread;
|
||||||
|
sMainStack;
|
||||||
|
sMainStackInfo;
|
||||||
|
sPiMgrCmdBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/boot_bss_viconfig.o {
|
||||||
|
gViConfigMode;
|
||||||
|
gViConfigModeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/boot_bss_z_std_dma.o {
|
||||||
|
sDmaMgrStackInfo;
|
||||||
|
sDmaMgrMsgQueue;
|
||||||
|
sDmaMgrMsgBuf;
|
||||||
|
sDmaMgrThread;
|
||||||
|
sDmaMgrStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/boot_bss_2.o {
|
||||||
|
__osThreadSave;
|
||||||
|
__Dom2SpeedParam;
|
||||||
|
__CartRomHandle;
|
||||||
|
__osPiAccessQueue;
|
||||||
|
__Dom1SpeedParam;
|
||||||
|
gPiMgrCmdQueue;
|
||||||
|
__osBaseTimer;
|
||||||
|
__osEventStateTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
build/ique-cn/code_bss_1.o {
|
||||||
|
D_8015FA8C;
|
||||||
|
__osMaxControllers;
|
||||||
|
D_8015FA88;
|
||||||
|
__osContLastCmd;
|
||||||
|
__osEepromTimerMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/code_bss_z_actor.o {
|
||||||
|
D_8015BBA8;
|
||||||
|
sCurCeilingPoly;
|
||||||
|
sCurCeilingBgId;
|
||||||
|
D_8015BC00;
|
||||||
|
D_8015BC10;
|
||||||
|
D_8015BC14;
|
||||||
|
D_8015BC18;
|
||||||
|
sNearestAttentionActor;
|
||||||
|
sPrioritizedAttentionActor;
|
||||||
|
sNearestAttentionActorDistSq;
|
||||||
|
sBgmEnemyDistSq;
|
||||||
|
sHighestAttentionPriority;
|
||||||
|
sAttentionPlayerRotY;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/code_bss_2.o {
|
||||||
|
__osContPifRam;
|
||||||
|
gSaveContext;
|
||||||
|
sUnknownBssPadding;
|
||||||
|
__osEepromTimerMsgQueue;
|
||||||
|
__osSiAccessQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
build/ique-cn/code_bss_3.o {
|
||||||
|
sCharTexSize;
|
||||||
|
sCharTexScale;
|
||||||
|
sOcarinaButtonAPrimR;
|
||||||
|
sOcarinaButtonAPrimB;
|
||||||
|
sOcarinaButtonAPrimG;
|
||||||
|
sOcarinaButtonAEnvR;
|
||||||
|
sOcarinaButtonAEnvB;
|
||||||
|
sOcarinaButtonAEnvG;
|
||||||
|
sOcarinaButtonCPrimR;
|
||||||
|
sOcarinaButtonCPrimB;
|
||||||
|
sOcarinaButtonCPrimG;
|
||||||
|
sOcarinaButtonCEnvR;
|
||||||
|
sOcarinaButtonCEnvB;
|
||||||
|
sOcarinaButtonCEnvG;
|
||||||
|
}
|
|
@ -1207,7 +1207,7 @@ assets:
|
||||||
- name: textures/nintendo_rogo_static
|
- name: textures/nintendo_rogo_static
|
||||||
xml_path: assets/xml/textures/nintendo_rogo_static_v2.xml
|
xml_path: assets/xml/textures/nintendo_rogo_static_v2.xml
|
||||||
- name: textures/parameter_static
|
- name: textures/parameter_static
|
||||||
xml_path: assets/xml/textures/parameter_static.xml
|
xml_path: assets/xml/textures/parameter_static_ique.xml
|
||||||
- name: textures/place_title_cards
|
- name: textures/place_title_cards
|
||||||
xml_path: assets/xml/textures/place_title_cards.xml
|
xml_path: assets/xml/textures/place_title_cards.xml
|
||||||
- name: textures/skyboxes
|
- name: textures/skyboxes
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
"OOT_REGION=REGION_JP",
|
"OOT_REGION=REGION_JP",
|
||||||
"PLATFORM_N64=1",
|
"PLATFORM_N64=1",
|
||||||
"PLATFORM_GC=0",
|
"PLATFORM_GC=0",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2"
|
"F3DEX_GBI_2"
|
||||||
|
@ -44,6 +45,7 @@
|
||||||
"OOT_REGION=REGION_JP",
|
"OOT_REGION=REGION_JP",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
|
@ -71,6 +73,7 @@
|
||||||
"OOT_REGION=REGION_JP",
|
"OOT_REGION=REGION_JP",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
|
@ -98,6 +101,7 @@
|
||||||
"OOT_REGION=REGION_US",
|
"OOT_REGION=REGION_US",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
|
@ -125,6 +129,7 @@
|
||||||
"OOT_REGION=REGION_US",
|
"OOT_REGION=REGION_US",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
|
@ -152,6 +157,7 @@
|
||||||
"OOT_REGION=REGION_EU",
|
"OOT_REGION=REGION_EU",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=1",
|
"DEBUG_FEATURES=1",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
"F3DEX_GBI_PL",
|
"F3DEX_GBI_PL",
|
||||||
|
@ -179,6 +185,7 @@
|
||||||
"OOT_REGION=REGION_EU",
|
"OOT_REGION=REGION_EU",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
|
@ -206,6 +213,7 @@
|
||||||
"OOT_REGION=REGION_EU",
|
"OOT_REGION=REGION_EU",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
|
@ -233,6 +241,7 @@
|
||||||
"OOT_REGION=REGION_JP",
|
"OOT_REGION=REGION_JP",
|
||||||
"PLATFORM_N64=0",
|
"PLATFORM_N64=0",
|
||||||
"PLATFORM_GC=1",
|
"PLATFORM_GC=1",
|
||||||
|
"PLATFORM_IQUE=0",
|
||||||
"DEBUG_FEATURES=0",
|
"DEBUG_FEATURES=0",
|
||||||
"NDEBUG",
|
"NDEBUG",
|
||||||
"F3DEX_GBI_2",
|
"F3DEX_GBI_2",
|
||||||
|
@ -241,6 +250,35 @@
|
||||||
],
|
],
|
||||||
"cStandard": "gnu89"
|
"cStandard": "gnu89"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "oot-ique-cn",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-m32"
|
||||||
|
],
|
||||||
|
"includePath": [
|
||||||
|
"include",
|
||||||
|
"include/libc",
|
||||||
|
"src",
|
||||||
|
"build/ique-cn",
|
||||||
|
".",
|
||||||
|
"extracted/ique-cn"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"_LANGUAGE_C",
|
||||||
|
"OOT_VERSION=IQUE_CN",
|
||||||
|
"OOT_REGION=REGION_US",
|
||||||
|
"PLATFORM_N64=0",
|
||||||
|
"PLATFORM_GC=0",
|
||||||
|
"PLATFORM_IQUE=1",
|
||||||
|
"BBPLAYER",
|
||||||
|
"DEBUG_FEATURES=0",
|
||||||
|
"NDEBUG",
|
||||||
|
"F3DEX_GBI_2",
|
||||||
|
"F3DEX_GBI_PL",
|
||||||
|
"GBI_DOWHILE"
|
||||||
|
],
|
||||||
|
"cStandard": "gnu89"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* - Argument 3: Cache load policy for the sequence (AudioCacheLoadType)
|
* - Argument 3: Cache load policy for the sequence (AudioCacheLoadType)
|
||||||
* - Argument 4: Sequence flags
|
* - Argument 4: Sequence flags
|
||||||
*/
|
*/
|
||||||
#if OOT_VERSION < PAL_1_0 || PLATFORM_GC
|
#if OOT_VERSION < PAL_1_0 || !PLATFORM_N64
|
||||||
#define SEQ_0_FLAGS SEQ_FLAG_FANFARE
|
#define SEQ_0_FLAGS SEQ_FLAG_FANFARE
|
||||||
#else
|
#else
|
||||||
#define SEQ_0_FLAGS SEQ_FLAG_FANFARE | SEQ_FLAG_ENEMY
|
#define SEQ_0_FLAGS SEQ_FLAG_FANFARE | SEQ_FLAG_ENEMY
|
||||||
|
|
|
@ -334,7 +334,7 @@
|
||||||
/* 0x3942 */ DEFINE_SFX(CHAN_4EA8, NA_SE_EN_BALINADE_THUNDER, 0x34, 3, 0, 0)
|
/* 0x3942 */ DEFINE_SFX(CHAN_4EA8, NA_SE_EN_BALINADE_THUNDER, 0x34, 3, 0, 0)
|
||||||
/* 0x3943 */ DEFINE_SFX(CHAN_415D, NA_SE_EN_BALINADE_BL_SPARK, 0x20, 2, 0, 0)
|
/* 0x3943 */ DEFINE_SFX(CHAN_415D, NA_SE_EN_BALINADE_BL_SPARK, 0x20, 2, 0, 0)
|
||||||
/* 0x3944 */ DEFINE_SFX(CHAN_4184, NA_SE_EN_BALINADE_BL_DEAD, 0x34, 3, 0, 0)
|
/* 0x3944 */ DEFINE_SFX(CHAN_4184, NA_SE_EN_BALINADE_BL_DEAD, 0x34, 3, 0, 0)
|
||||||
#if OOT_VERSION < PAL_1_0 || PLATFORM_GC
|
#if OOT_VERSION < PAL_1_0 || !PLATFORM_N64
|
||||||
/* 0x3945 */ DEFINE_SFX(CHAN_4E86, NA_SE_EN_BALINADE_BREAK2, 0x30, 3, 0, 0)
|
/* 0x3945 */ DEFINE_SFX(CHAN_4E86, NA_SE_EN_BALINADE_BREAK2, 0x30, 3, 0, 0)
|
||||||
#else
|
#else
|
||||||
/* 0x3945 */ DEFINE_SFX(CHAN_4E86, NA_SE_EN_BALINADE_BREAK2, 0x34, 3, 0, 0)
|
/* 0x3945 */ DEFINE_SFX(CHAN_4E86, NA_SE_EN_BALINADE_BREAK2, 0x34, 3, 0, 0)
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
/* 0x281F */ DEFINE_SFX(CHAN_1B61, NA_SE_EV_TBOX_UNLOCK, 0x30, 0, 0, 0)
|
/* 0x281F */ DEFINE_SFX(CHAN_1B61, NA_SE_EV_TBOX_UNLOCK, 0x30, 0, 0, 0)
|
||||||
/* 0x2820 */ DEFINE_SFX(CHAN_1B7D, NA_SE_EV_TBOX_OPEN, 0x30, 0, 0, 0)
|
/* 0x2820 */ DEFINE_SFX(CHAN_1B7D, NA_SE_EV_TBOX_OPEN, 0x30, 0, 0, 0)
|
||||||
/* 0x2821 */ DEFINE_SFX(CHAN_1B93, NA_SE_SY_TIMER, 0xA0, 0, 0, SFX_FLAG_13 | SFX_FLAG_3)
|
/* 0x2821 */ DEFINE_SFX(CHAN_1B93, NA_SE_SY_TIMER, 0xA0, 0, 0, SFX_FLAG_13 | SFX_FLAG_3)
|
||||||
#if OOT_VERSION < PAL_1_0 || PLATFORM_GC
|
#if OOT_VERSION < PAL_1_0 || !PLATFORM_N64
|
||||||
/* 0x2822 */ DEFINE_SFX(CHAN_1BE9, NA_SE_EV_FLAME_IGNITION, 0x20, 2, 0, 0)
|
/* 0x2822 */ DEFINE_SFX(CHAN_1BE9, NA_SE_EV_FLAME_IGNITION, 0x20, 2, 0, 0)
|
||||||
#else
|
#else
|
||||||
/* 0x2822 */ DEFINE_SFX(CHAN_1BE9, NA_SE_EV_FLAME_IGNITION, 0x2D, 2, 0, 0)
|
/* 0x2822 */ DEFINE_SFX(CHAN_1BE9, NA_SE_EV_FLAME_IGNITION, 0x2D, 2, 0, 0)
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
/* 0x285C */ DEFINE_SFX(CHAN_2374, NA_SE_EV_BLOCKSINK, 0x30, 2, 0, 0)
|
/* 0x285C */ DEFINE_SFX(CHAN_2374, NA_SE_EV_BLOCKSINK, 0x30, 2, 0, 0)
|
||||||
/* 0x285D */ DEFINE_SFX(CHAN_2389, NA_SE_EV_CROWD, 0x30, 0, 0, SFX_FLAG_13 | SFX_FLAG_12 | SFX_FLAG_11)
|
/* 0x285D */ DEFINE_SFX(CHAN_2389, NA_SE_EV_CROWD, 0x30, 0, 0, SFX_FLAG_13 | SFX_FLAG_12 | SFX_FLAG_11)
|
||||||
/* 0x285E */ DEFINE_SFX(CHAN_23A6, NA_SE_EV_WATER_LEVEL_DOWN, 0x30, 0, 0, 0)
|
/* 0x285E */ DEFINE_SFX(CHAN_23A6, NA_SE_EV_WATER_LEVEL_DOWN, 0x30, 0, 0, 0)
|
||||||
#if OOT_VERSION < PAL_1_0 || PLATFORM_GC
|
#if OOT_VERSION < PAL_1_0 || !PLATFORM_N64
|
||||||
/* 0x285F */ DEFINE_SFX(CHAN_23D5, NA_SE_EV_NAVY_VANISH, 0x30, 0, 0, 0)
|
/* 0x285F */ DEFINE_SFX(CHAN_23D5, NA_SE_EV_NAVY_VANISH, 0x30, 0, 0, 0)
|
||||||
#else
|
#else
|
||||||
/* 0x285F */ DEFINE_SFX(CHAN_23D5, NA_SE_EV_NAVY_VANISH, 0x2C, 0, 0, 0)
|
/* 0x285F */ DEFINE_SFX(CHAN_23D5, NA_SE_EV_NAVY_VANISH, 0x2C, 0, 0, 0)
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
/* 0x1810 */ DEFINE_SFX(CHAN_10A2, NA_SE_IT_BOOMERANG_FLY, 0x30, 0, 0, SFX_FLAG_10)
|
/* 0x1810 */ DEFINE_SFX(CHAN_10A2, NA_SE_IT_BOOMERANG_FLY, 0x30, 0, 0, SFX_FLAG_10)
|
||||||
/* 0x1811 */ DEFINE_SFX(CHAN_10D2, NA_SE_IT_SWORD_STRIKE, 0x40, 2, 0, 0)
|
/* 0x1811 */ DEFINE_SFX(CHAN_10D2, NA_SE_IT_SWORD_STRIKE, 0x40, 2, 0, 0)
|
||||||
/* 0x1812 */ DEFINE_SFX(CHAN_10E6, NA_SE_IT_HAMMER_SWING, 0x30, 0, 1, 0)
|
/* 0x1812 */ DEFINE_SFX(CHAN_10E6, NA_SE_IT_HAMMER_SWING, 0x30, 0, 1, 0)
|
||||||
#if OOT_VERSION < PAL_1_0 || PLATFORM_GC
|
#if OOT_VERSION < PAL_1_0 || !PLATFORM_N64
|
||||||
/* 0x1813 */ DEFINE_SFX(CHAN_10F4, NA_SE_IT_HOOKSHOT_REFLECT, 0x30, 0, 0, 0)
|
/* 0x1813 */ DEFINE_SFX(CHAN_10F4, NA_SE_IT_HOOKSHOT_REFLECT, 0x30, 0, 0, 0)
|
||||||
#else
|
#else
|
||||||
/* 0x1813 */ DEFINE_SFX(CHAN_10F4, NA_SE_IT_HOOKSHOT_REFLECT, 0x20, 0, 0, 0)
|
/* 0x1813 */ DEFINE_SFX(CHAN_10F4, NA_SE_IT_HOOKSHOT_REFLECT, 0x20, 0, 0, 0)
|
||||||
|
|
|
@ -4,7 +4,11 @@
|
||||||
#define OS_MESG_NOBLOCK 0
|
#define OS_MESG_NOBLOCK 0
|
||||||
#define OS_MESG_BLOCK 1
|
#define OS_MESG_BLOCK 1
|
||||||
|
|
||||||
|
#ifndef BBPLAYER
|
||||||
#define OS_NUM_EVENTS 15
|
#define OS_NUM_EVENTS 15
|
||||||
|
#else
|
||||||
|
#define OS_NUM_EVENTS 31
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */
|
#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */
|
||||||
#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */
|
#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */
|
||||||
|
|
|
@ -18,5 +18,7 @@ SECTIONS {
|
||||||
* To avoid dealing with this, we just discard all .gptab sections.
|
* To avoid dealing with this, we just discard all .gptab sections.
|
||||||
*/
|
*/
|
||||||
*(.gptab.*)
|
*(.gptab.*)
|
||||||
|
/* Inhibit merging of COMMON into scommon */
|
||||||
|
*(.scommon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
include "$(BUILD_DIR)/src/libultra/os/writebackdcache.o"
|
include "$(BUILD_DIR)/src/libultra/os/writebackdcache.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/vigetnextframebuf.o"
|
include "$(BUILD_DIR)/src/libultra/io/vigetnextframebuf.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/pimgr.o"
|
include "$(BUILD_DIR)/src/libultra/io/pimgr.o"
|
||||||
|
include "$(BUILD_DIR)/src/libultra/os/kdebugserver.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/devmgr.o"
|
include "$(BUILD_DIR)/src/libultra/io/devmgr.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/pirawdma.o"
|
include "$(BUILD_DIR)/src/libultra/io/pirawdma.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/os/virtualtophysical.o"
|
include "$(BUILD_DIR)/src/libultra/os/virtualtophysical.o"
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
include "$(BUILD_DIR)/src/libultra/os/sethwintrroutine.o"
|
include "$(BUILD_DIR)/src/libultra/os/sethwintrroutine.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/os/gethwintrroutine.o"
|
include "$(BUILD_DIR)/src/libultra/os/gethwintrroutine.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/pimgr.o"
|
include "$(BUILD_DIR)/src/libultra/io/pimgr.o"
|
||||||
|
include "$(BUILD_DIR)/src/libultra/os/kdebugserver.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/epirawdma.o"
|
include "$(BUILD_DIR)/src/libultra/io/epirawdma.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/epiread.o"
|
include "$(BUILD_DIR)/src/libultra/io/epiread.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/epidma.o"
|
include "$(BUILD_DIR)/src/libultra/io/epidma.o"
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
include "$(BUILD_DIR)/src/libultra/os/writebackdcache.o"
|
include "$(BUILD_DIR)/src/libultra/os/writebackdcache.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/vigetnextframebuf.o"
|
include "$(BUILD_DIR)/src/libultra/io/vigetnextframebuf.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/pimgr.o"
|
include "$(BUILD_DIR)/src/libultra/io/pimgr.o"
|
||||||
|
include "$(BUILD_DIR)/src/libultra/os/kdebugserver.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/devmgr.o"
|
include "$(BUILD_DIR)/src/libultra/io/devmgr.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/io/pirawdma.o"
|
include "$(BUILD_DIR)/src/libultra/io/pirawdma.o"
|
||||||
include "$(BUILD_DIR)/src/libultra/os/virtualtophysical.o"
|
include "$(BUILD_DIR)/src/libultra/os/virtualtophysical.o"
|
||||||
|
|
25
spec/spec
25
spec/spec
|
@ -17,6 +17,12 @@ endseg
|
||||||
beginseg
|
beginseg
|
||||||
name "boot"
|
name "boot"
|
||||||
|
|
||||||
|
#if PLATFORM_IQUE
|
||||||
|
include "*$(BUILD_DIR)/boot_bss_1.o"
|
||||||
|
include "*$(BUILD_DIR)/boot_bss_boot_main.o"
|
||||||
|
include "*$(BUILD_DIR)/boot_bss_idle.o"
|
||||||
|
include "*$(BUILD_DIR)/boot_bss_viconfig.o"
|
||||||
|
#endif
|
||||||
include "$(BUILD_DIR)/src/boot/boot_main.o"
|
include "$(BUILD_DIR)/src/boot/boot_main.o"
|
||||||
include "$(BUILD_DIR)/src/boot/idle.o"
|
include "$(BUILD_DIR)/src/boot/idle.o"
|
||||||
#if OOT_VERSION >= PAL_1_0
|
#if OOT_VERSION >= PAL_1_0
|
||||||
|
@ -24,6 +30,9 @@ beginseg
|
||||||
#endif
|
#endif
|
||||||
include "$(BUILD_DIR)/src/boot/carthandle.o"
|
include "$(BUILD_DIR)/src/boot/carthandle.o"
|
||||||
include "$(BUILD_DIR)/src/boot/z_std_dma.o"
|
include "$(BUILD_DIR)/src/boot/z_std_dma.o"
|
||||||
|
#if PLATFORM_IQUE
|
||||||
|
include "*$(BUILD_DIR)/boot_bss_z_std_dma.o"
|
||||||
|
#endif
|
||||||
#if !PLATFORM_IQUE
|
#if !PLATFORM_IQUE
|
||||||
include "$(BUILD_DIR)/src/boot/yaz0.o"
|
include "$(BUILD_DIR)/src/boot/yaz0.o"
|
||||||
#else
|
#else
|
||||||
|
@ -101,6 +110,10 @@ beginseg
|
||||||
include "$(BUILD_DIR)/src/libultra/libc/xprintf.o"
|
include "$(BUILD_DIR)/src/libultra/libc/xprintf.o"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PLATFORM_IQUE
|
||||||
|
include "*$(BUILD_DIR)/boot_bss_2.o"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Functions that GCC-compiled code may depend on, placed in boot so they will always be loaded
|
// Functions that GCC-compiled code may depend on, placed in boot so they will always be loaded
|
||||||
#ifdef COMPILER_GCC
|
#ifdef COMPILER_GCC
|
||||||
include "$(BUILD_DIR)/src/libultra/libc/string.o"
|
include "$(BUILD_DIR)/src/libultra/libc/string.o"
|
||||||
|
@ -505,6 +518,9 @@ beginseg
|
||||||
after "dmadata"
|
after "dmadata"
|
||||||
align 0x20
|
align 0x20
|
||||||
|
|
||||||
|
#if PLATFORM_IQUE
|
||||||
|
include "*$(BUILD_DIR)/code_bss_1.o"
|
||||||
|
#endif
|
||||||
include "$(BUILD_DIR)/src/code/z_en_a_keep.o"
|
include "$(BUILD_DIR)/src/code/z_en_a_keep.o"
|
||||||
include "$(BUILD_DIR)/src/code/z_en_item00.o"
|
include "$(BUILD_DIR)/src/code/z_en_item00.o"
|
||||||
include "$(BUILD_DIR)/src/code/z_eff_blure.o"
|
include "$(BUILD_DIR)/src/code/z_eff_blure.o"
|
||||||
|
@ -518,6 +534,9 @@ beginseg
|
||||||
include "$(BUILD_DIR)/src/code/flg_set.o"
|
include "$(BUILD_DIR)/src/code/flg_set.o"
|
||||||
include "$(BUILD_DIR)/src/code/z_DLF.o"
|
include "$(BUILD_DIR)/src/code/z_DLF.o"
|
||||||
include "$(BUILD_DIR)/src/code/z_actor.o"
|
include "$(BUILD_DIR)/src/code/z_actor.o"
|
||||||
|
#if PLATFORM_IQUE
|
||||||
|
include "*$(BUILD_DIR)/code_bss_z_actor.o"
|
||||||
|
#endif
|
||||||
include "$(BUILD_DIR)/src/code/z_actor_dlftbls.o"
|
include "$(BUILD_DIR)/src/code/z_actor_dlftbls.o"
|
||||||
include "$(BUILD_DIR)/src/code/z_bgcheck.o"
|
include "$(BUILD_DIR)/src/code/z_bgcheck.o"
|
||||||
include "$(BUILD_DIR)/src/code/z_bg_collect.o"
|
include "$(BUILD_DIR)/src/code/z_bg_collect.o"
|
||||||
|
@ -778,6 +797,11 @@ beginseg
|
||||||
include "$(BUILD_DIR)/src/libc/sqrt.o"
|
include "$(BUILD_DIR)/src/libc/sqrt.o"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PLATFORM_IQUE
|
||||||
|
include "*$(BUILD_DIR)/code_bss_2.o"
|
||||||
|
include "*$(BUILD_DIR)/code_bss_3.o"
|
||||||
|
#endif
|
||||||
|
|
||||||
// For some reason, the data sections of z_message and z_game_over are
|
// For some reason, the data sections of z_message and z_game_over are
|
||||||
// placed near the rodata sections of other files, so we first build this
|
// placed near the rodata sections of other files, so we first build this
|
||||||
// combined object before the final link.
|
// combined object before the final link.
|
||||||
|
@ -816,7 +840,6 @@ beginseg
|
||||||
include "$(BUILD_DIR)/src/libultra/mgu/mtxl2f.o"
|
include "$(BUILD_DIR)/src/libultra/mgu/mtxl2f.o"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
endseg
|
endseg
|
||||||
|
|
||||||
beginseg
|
beginseg
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
* DPad-Down disables sending fault pages over osSyncPrintf.
|
* DPad-Down disables sending fault pages over osSyncPrintf.
|
||||||
*/
|
*/
|
||||||
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:144 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160" \
|
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:144 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160" \
|
||||||
"gc-us-mq:160"
|
"gc-us-mq:160 ique-cn:160"
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "alloca.h"
|
#include "alloca.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
extern uintptr_t gSegments[NUM_SEGMENTS];
|
extern uintptr_t gSegments[NUM_SEGMENTS];
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:252 gc-eu-mq:252 gc-jp:252 gc-jp-ce:252 gc-jp-mq:252 gc-us:252 gc-us-mq:252" \
|
#pragma increment_block_number "gc-eu:252 gc-eu-mq:252 gc-jp:252 gc-jp-ce:252 gc-jp-mq:252 gc-us:252 gc-us-mq:252" \
|
||||||
"ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
"ique-cn:252 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
||||||
|
|
||||||
extern struct PreNmiBuff* gAppNmiBufferPtr;
|
extern struct PreNmiBuff* gAppNmiBufferPtr;
|
||||||
extern struct Scheduler gScheduler;
|
extern struct Scheduler gScheduler;
|
||||||
|
@ -24,7 +24,7 @@ extern struct IrqMgr gIrqMgr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:144 gc-eu-mq:144 gc-jp:144 gc-jp-ce:144 gc-jp-mq:144 gc-us:144 gc-us-mq:144" \
|
#pragma increment_block_number "gc-eu:144 gc-eu-mq:144 gc-jp:144 gc-jp-ce:144 gc-jp-mq:144 gc-us:144 gc-us-mq:144" \
|
||||||
"ntsc-1.0:122 ntsc-1.1:122 ntsc-1.2:122 pal-1.0:120 pal-1.1:120"
|
"ique-cn:128 ntsc-1.0:122 ntsc-1.1:122 ntsc-1.2:122 pal-1.0:120 pal-1.1:120"
|
||||||
|
|
||||||
extern u8 _buffersSegmentEnd[];
|
extern u8 _buffersSegmentEnd[];
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "sys_math3d.h"
|
#include "sys_math3d.h"
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:97 gc-eu-mq:97 gc-jp:97 gc-jp-ce:97 gc-jp-mq:97 gc-us:97 gc-us-mq:97" \
|
#pragma increment_block_number "gc-eu:97 gc-eu-mq:97 gc-jp:97 gc-jp-ce:97 gc-jp-mq:97 gc-us:97 gc-us-mq:97 ique-cn:97" \
|
||||||
"ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:79 pal-1.0:80 pal-1.1:80"
|
"ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:79 pal-1.0:80 pal-1.1:80"
|
||||||
|
|
||||||
s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB,
|
s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB,
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
||||||
"ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
|
"ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
|
||||||
|
|
||||||
static CollisionPoly* sCurCeilingPoly;
|
CollisionPoly* sCurCeilingPoly;
|
||||||
static s32 sCurCeilingBgId;
|
s32 sCurCeilingBgId;
|
||||||
|
|
||||||
#if DEBUG_FEATURES
|
#if DEBUG_FEATURES
|
||||||
#define ACTOR_DEBUG_PRINTF \
|
#define ACTOR_DEBUG_PRINTF \
|
||||||
|
@ -265,7 +265,10 @@ typedef struct AttentionColor {
|
||||||
/* 0x04 */ Color_RGBA8 secondary; // Used for Navi's outer color
|
/* 0x04 */ Color_RGBA8 secondary; // Used for Navi's outer color
|
||||||
} AttentionColor; // size = 0x8
|
} AttentionColor; // size = 0x8
|
||||||
|
|
||||||
AttentionColor sAttentionColors[ACTORCAT_MAX + 1] = {
|
// Needs to be static to work around an EGCS codegen bug in Attention_SetNaviState on iQue builds.
|
||||||
|
// If this isn't static, accessing the element at offset 4 into the struct (secondary.r) will not
|
||||||
|
// be offset correctly in the compiled code.
|
||||||
|
static AttentionColor sAttentionColors[ACTORCAT_MAX + 1] = {
|
||||||
{ { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, // ACTORCAT_SWITCH
|
{ { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, // ACTORCAT_SWITCH
|
||||||
{ { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, // ACTORCAT_BG
|
{ { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, // ACTORCAT_BG
|
||||||
{ { 255, 255, 255, 255 }, { 0, 0, 255, 0 } }, // ACTORCAT_PLAYER
|
{ { 255, 255, 255, 255 }, { 0, 0, 255, 0 } }, // ACTORCAT_PLAYER
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
|
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
||||||
"ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
"ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
||||||
|
|
||||||
s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags);
|
s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags);
|
||||||
s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange);
|
s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange);
|
||||||
|
@ -3639,7 +3639,7 @@ s32 Camera_KeepOn3(Camera* camera) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
||||||
"ntsc-1.0:124 ntsc-1.1:124 ntsc-1.2:124 pal-1.0:122 pal-1.1:122"
|
"ique-cn:128 ntsc-1.0:124 ntsc-1.1:124 ntsc-1.2:124 pal-1.0:122 pal-1.1:122"
|
||||||
|
|
||||||
s32 Camera_KeepOn4(Camera* camera) {
|
s32 Camera_KeepOn4(Camera* camera) {
|
||||||
static Vec3f D_8015BD50;
|
static Vec3f D_8015BD50;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "z_lib.h"
|
#include "z_lib.h"
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
||||||
"ntsc-1.0:96 ntsc-1.1:96 ntsc-1.2:96 pal-1.0:96 pal-1.1:96"
|
"ique-cn:128 ntsc-1.0:96 ntsc-1.1:96 ntsc-1.2:96 pal-1.0:96 pal-1.1:96"
|
||||||
|
|
||||||
typedef s32 (*ColChkResetFunc)(PlayState*, Collider*);
|
typedef s32 (*ColChkResetFunc)(PlayState*, Collider*);
|
||||||
typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*);
|
typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*);
|
||||||
|
@ -2225,7 +2225,7 @@ void CollisionCheck_ATTrisVsACCyl(PlayState* play, CollisionCheckContext* colChk
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:252 gc-eu-mq:252 gc-jp:252 gc-jp-ce:252 gc-jp-mq:252 gc-us:252 gc-us-mq:252" \
|
#pragma increment_block_number "gc-eu:252 gc-eu-mq:252 gc-jp:252 gc-jp-ce:252 gc-jp-mq:252 gc-us:252 gc-us-mq:252" \
|
||||||
"ntsc-1.0:252 ntsc-1.1:252 ntsc-1.2:252 pal-1.0:252 pal-1.1:252"
|
"ique-cn:252 ntsc-1.0:252 ntsc-1.1:252 ntsc-1.2:252 pal-1.0:252 pal-1.1:252"
|
||||||
|
|
||||||
void CollisionCheck_ATCylVsACQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, Collider* acCol) {
|
void CollisionCheck_ATCylVsACQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, Collider* acCol) {
|
||||||
static TriNorm tri1;
|
static TriNorm tri1;
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
"ntsc-1.0:176 ntsc-1.1:176 ntsc-1.2:176 pal-1.0:160 pal-1.1:160"
|
"ntsc-1.0:176 ntsc-1.1:176 ntsc-1.2:176 pal-1.0:160 pal-1.1:160"
|
||||||
|
|
||||||
ALIGNED(16) SaveContext gSaveContext;
|
ALIGNED(16) SaveContext gSaveContext;
|
||||||
|
#if PLATFORM_IQUE
|
||||||
|
// Unknown bss padding, placed here for matching
|
||||||
|
char sUnknownBssPadding[0x20];
|
||||||
|
#endif
|
||||||
u32 D_8015FA88;
|
u32 D_8015FA88;
|
||||||
u32 D_8015FA8C;
|
u32 D_8015FA8C;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ typedef struct InputCombo {
|
||||||
} InputCombo; // size = 0x4
|
} InputCombo; // size = 0x4
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \
|
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \
|
||||||
"ntsc-1.0:160 ntsc-1.1:160 ntsc-1.2:160 pal-1.0:160 pal-1.1:160"
|
"ique-cn:128 ntsc-1.0:160 ntsc-1.1:160 ntsc-1.2:160 pal-1.0:160 pal-1.1:160"
|
||||||
|
|
||||||
RegEditor* gRegEditor;
|
RegEditor* gRegEditor;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
||||||
"ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:192 pal-1.1:192"
|
"ique-cn:192 ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:192 pal-1.1:192"
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
||||||
"ntsc-1.0:208 ntsc-1.1:208 ntsc-1.2:208 pal-1.0:220 pal-1.1:220"
|
"ique-cn:192 ntsc-1.0:208 ntsc-1.1:208 ntsc-1.2:208 pal-1.0:220 pal-1.1:220"
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "ultra64.h"
|
#include "ultra64.h"
|
||||||
|
@ -215,7 +215,7 @@ s16 sSunDepthTestX;
|
||||||
s16 sSunDepthTestY;
|
s16 sSunDepthTestY;
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:240 gc-eu-mq:240 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \
|
#pragma increment_block_number "gc-eu:240 gc-eu-mq:240 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \
|
||||||
"ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:240 pal-1.1:240"
|
"ique-cn:224 ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:240 pal-1.1:240"
|
||||||
|
|
||||||
LightNode* sNGameOverLightNode;
|
LightNode* sNGameOverLightNode;
|
||||||
LightInfo sNGameOverLightInfo;
|
LightInfo sNGameOverLightInfo;
|
||||||
|
|
|
@ -4129,6 +4129,8 @@ void Message_Update(PlayState* play) {
|
||||||
};
|
};
|
||||||
#if OOT_VERSION < GC_US
|
#if OOT_VERSION < GC_US
|
||||||
static s32 sUnknown = 0;
|
static s32 sUnknown = 0;
|
||||||
|
#elif PLATFORM_IQUE
|
||||||
|
static u16 sUnknown = 0;
|
||||||
#endif
|
#endif
|
||||||
static char D_80153D74 = 0;
|
static char D_80153D74 = 0;
|
||||||
MessageContext* msgCtx = &play->msgCtx;
|
MessageContext* msgCtx = &play->msgCtx;
|
||||||
|
|
|
@ -4,7 +4,9 @@ OSPifRam __osContPifRam;
|
||||||
u8 __osContLastCmd;
|
u8 __osContLastCmd;
|
||||||
u8 __osMaxControllers; // always 4
|
u8 __osMaxControllers; // always 4
|
||||||
|
|
||||||
|
#ifndef BBPLAYER
|
||||||
OSTimer __osEepromTimer;
|
OSTimer __osEepromTimer;
|
||||||
|
#endif
|
||||||
OSMesgQueue __osEepromTimerMsgQueue;
|
OSMesgQueue __osEepromTimerMsgQueue;
|
||||||
OSMesg __osEepromTimerMsg;
|
OSMesg __osEepromTimerMsg;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
u32 __osPiAccessQueueEnabled = false;
|
u32 __osPiAccessQueueEnabled = false;
|
||||||
OSMesg piAccessBuf[1];
|
static OSMesg piAccessBuf[1];
|
||||||
OSMesgQueue __osPiAccessQueue;
|
OSMesgQueue __osPiAccessQueue;
|
||||||
|
|
||||||
void __osPiCreateAccessQueue(void) {
|
void __osPiCreateAccessQueue(void) {
|
||||||
|
|
|
@ -6,11 +6,10 @@ OSDevMgr __osPiDevMgr = { 0 };
|
||||||
|
|
||||||
OSPiHandle __Dom1SpeedParam;
|
OSPiHandle __Dom1SpeedParam;
|
||||||
OSPiHandle __Dom2SpeedParam;
|
OSPiHandle __Dom2SpeedParam;
|
||||||
OSThread piThread;
|
static OSThread piThread;
|
||||||
STACK(piStackThread, 0x1000);
|
static STACK(piThreadStack, 0x1000);
|
||||||
OSMesgQueue piEventQueue;
|
static OSMesgQueue piEventQueue;
|
||||||
OSMesg piEventBuf[2];
|
static OSMesg piEventBuf[2];
|
||||||
OSThread __osThreadSave;
|
|
||||||
|
|
||||||
OSPiHandle* __osPiTable = NULL;
|
OSPiHandle* __osPiTable = NULL;
|
||||||
OSPiHandle* __osCurrentHandle[] = {
|
OSPiHandle* __osCurrentHandle[] = {
|
||||||
|
@ -47,7 +46,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQueue, OSMesg* cmdBuf, s32 cmd
|
||||||
__osPiDevMgr.dma = __osPiRawStartDma;
|
__osPiDevMgr.dma = __osPiRawStartDma;
|
||||||
__osPiDevMgr.edma = __osEPiRawStartDma;
|
__osPiDevMgr.edma = __osEPiRawStartDma;
|
||||||
|
|
||||||
osCreateThread(&piThread, 0, __osDevMgrMain, (void*)&__osPiDevMgr, STACK_TOP(piStackThread), pri);
|
osCreateThread(&piThread, 0, __osDevMgrMain, (void*)&__osPiDevMgr, STACK_TOP(piThreadStack), pri);
|
||||||
osStartThread(&piThread);
|
osStartThread(&piThread);
|
||||||
|
|
||||||
__osRestoreInt(prevInt);
|
__osRestoreInt(prevInt);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
OSMesg siAccessBuf[1];
|
static OSMesg siAccessBuf[1];
|
||||||
OSMesgQueue __osSiAccessQueue;
|
OSMesgQueue __osSiAccessQueue;
|
||||||
u32 __osSiAccessQueueEnabled = false;
|
u32 __osSiAccessQueueEnabled = false;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
#include "ultra64/internal.h"
|
#include "ultra64/internal.h"
|
||||||
|
|
||||||
OSThread viThread;
|
static OSThread viThread;
|
||||||
STACK(viThreadStack, 0x1000);
|
static STACK(viThreadStack, 0x1000);
|
||||||
OSMesgQueue viEventQueue;
|
static OSMesgQueue viEventQueue;
|
||||||
OSMesg viEventBuf[5];
|
static OSMesg viEventBuf[5];
|
||||||
OSIoMesg viRetraceMsg;
|
static OSIoMesg viRetraceMsg;
|
||||||
OSIoMesg viCounterMsg;
|
static OSIoMesg viCounterMsg;
|
||||||
OSDevMgr __osViDevMgr = { 0 };
|
OSDevMgr __osViDevMgr = { 0 };
|
||||||
u32 __additional_scanline = 0;
|
u32 __additional_scanline = 0;
|
||||||
|
|
||||||
|
|
3
src/libultra/os/kdebugserver.c
Normal file
3
src/libultra/os/kdebugserver.c
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include "ultra64.h"
|
||||||
|
|
||||||
|
OSThread __osThreadSave;
|
|
@ -125,22 +125,22 @@ static ColliderCylinderInit sLightBallCylinderInit = {
|
||||||
static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 };
|
static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 };
|
||||||
static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f };
|
static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:0" \
|
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \
|
||||||
"ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
|
"ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
|
||||||
|
|
||||||
static EnGanonMant* sCape;
|
static EnGanonMant* sCape;
|
||||||
|
|
||||||
// TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving
|
// TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving
|
||||||
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
|
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
|
||||||
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
||||||
"ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
"ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
||||||
|
|
||||||
static s32 sSeed1;
|
static s32 sSeed1;
|
||||||
static s32 sSeed2;
|
static s32 sSeed2;
|
||||||
static s32 sSeed3;
|
static s32 sSeed3;
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
||||||
"ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
"ique-cn:192 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
||||||
|
|
||||||
static BossGanon* sGanondorf;
|
static BossGanon* sGanondorf;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "assets/objects/object_toki_objects/object_toki_objects.h"
|
#include "assets/objects/object_toki_objects/object_toki_objects.h"
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
||||||
"ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
"ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
||||||
|
|
||||||
#define FLAGS (ACTOR_FLAG_UPDATE_CULLING_DISABLED | ACTOR_FLAG_DRAW_CULLING_DISABLED)
|
#define FLAGS (ACTOR_FLAG_UPDATE_CULLING_DISABLED | ACTOR_FLAG_DRAW_CULLING_DISABLED)
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
#include "assets/scenes/dungeons/ice_doukutu/ice_doukutu_scene.h"
|
#include "assets/scenes/dungeons/ice_doukutu/ice_doukutu_scene.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:0" \
|
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:128" \
|
||||||
"ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
|
"ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
|
||||||
|
|
||||||
#define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED
|
#define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED
|
||||||
|
|
||||||
|
@ -1397,7 +1397,7 @@ void func_80B3F3D8(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:64 gc-eu-mq:64 gc-jp:64 gc-jp-ce:64 gc-jp-mq:64 gc-us:64 gc-us-mq:64" \
|
#pragma increment_block_number "gc-eu:64 gc-eu-mq:64 gc-jp:64 gc-jp-ce:64 gc-jp-mq:64 gc-us:64 gc-us-mq:64" \
|
||||||
"ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64"
|
"ique-cn:128 ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64"
|
||||||
|
|
||||||
void EnXc_PlayDiveSFX(Vec3f* src, PlayState* play) {
|
void EnXc_PlayDiveSFX(Vec3f* src, PlayState* play) {
|
||||||
static Vec3f D_80B42DA0;
|
static Vec3f D_80B42DA0;
|
||||||
|
|
|
@ -454,7 +454,6 @@ static f32 sFishGroupAngle1;
|
||||||
static f32 sFishGroupAngle2;
|
static f32 sFishGroupAngle2;
|
||||||
static f32 sFishGroupAngle3;
|
static f32 sFishGroupAngle3;
|
||||||
static FishingEffect sEffects[FISHING_EFFECT_COUNT];
|
static FishingEffect sEffects[FISHING_EFFECT_COUNT];
|
||||||
static Vec3f sStreamSfxProjectedPos;
|
|
||||||
|
|
||||||
void Fishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) {
|
void Fishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) {
|
||||||
collider->elements[index].dim.worldSphere.center.x = pos->x;
|
collider->elements[index].dim.worldSphere.center.x = pos->x;
|
||||||
|
@ -5139,6 +5138,7 @@ static Vec3s sSinkingLureLocations[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) {
|
void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) {
|
||||||
|
static Vec3f sStreamSfxProjectedPos;
|
||||||
PlayState* play = play2;
|
PlayState* play = play2;
|
||||||
Fishing* this = (Fishing*)thisx;
|
Fishing* this = (Fishing*)thisx;
|
||||||
Vec3f multiVecSrc;
|
Vec3f multiVecSrc;
|
||||||
|
|
|
@ -332,21 +332,21 @@ void Player_Action_CsAction(Player* this, PlayState* play);
|
||||||
// .bss part 1
|
// .bss part 1
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
||||||
"ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64"
|
"ique-cn:128 ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64"
|
||||||
|
|
||||||
static s32 D_80858AA0;
|
static s32 D_80858AA0;
|
||||||
|
|
||||||
// TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving
|
// TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving
|
||||||
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
|
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
|
||||||
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
|
||||||
"ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192"
|
"ique-cn:128 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192"
|
||||||
|
|
||||||
static s32 sSavedCurrentMask;
|
static s32 sSavedCurrentMask;
|
||||||
static Vec3f sInteractWallCheckResult;
|
static Vec3f sInteractWallCheckResult;
|
||||||
static Input* sControlInput;
|
static Input* sControlInput;
|
||||||
|
|
||||||
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
|
||||||
"ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
"ique-cn:192 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
|
||||||
|
|
||||||
// .data
|
// .data
|
||||||
|
|
||||||
|
|
|
@ -902,9 +902,14 @@ static void* sPromptChoiceTexs[][2] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! @bug On the iQue version, kaleido bss is reported to be just 0x10 bytes large in the relocation section. This is
|
||||||
|
//! likely due to not counting the size of COMMON symbols in the overlay. sPlayerPreRender was likely originally
|
||||||
|
//! non-static, but we make it static here to match the bss order and patch the relocation section later in the build
|
||||||
|
//! as our relocation generator does count COMMON symbols.
|
||||||
|
|
||||||
static u8 D_808321A8[5];
|
static u8 D_808321A8[5];
|
||||||
static PreRender sPlayerPreRender;
|
static PreRender sPlayerPreRender;
|
||||||
static void* sPreRenderCvg;
|
void* sPreRenderCvg;
|
||||||
|
|
||||||
void KaleidoScope_SetupPlayerPreRender(PlayState* play) {
|
void KaleidoScope_SetupPlayerPreRender(PlayState* play) {
|
||||||
Gfx* gfx;
|
Gfx* gfx;
|
||||||
|
|
|
@ -38,6 +38,7 @@ all: $(PROGRAMS) $(IDO_RECOMP_5_3_DIR) $(IDO_RECOMP_7_1_DIR) $(EGCS_DIR)
|
||||||
$(MAKE) -C ZAPD
|
$(MAKE) -C ZAPD
|
||||||
$(MAKE) -C fado
|
$(MAKE) -C fado
|
||||||
$(MAKE) -C audio
|
$(MAKE) -C audio
|
||||||
|
$(MAKE) -C com-plugin
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(PROGRAMS) $(addsuffix .exe,$(PROGRAMS))
|
$(RM) $(PROGRAMS) $(addsuffix .exe,$(PROGRAMS))
|
||||||
|
@ -45,6 +46,7 @@ clean:
|
||||||
$(MAKE) -C ZAPD clean
|
$(MAKE) -C ZAPD clean
|
||||||
$(MAKE) -C fado clean
|
$(MAKE) -C fado clean
|
||||||
$(MAKE) -C audio clean
|
$(MAKE) -C audio clean
|
||||||
|
$(MAKE) -C com-plugin clean
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(MAKE) -C audio distclean
|
$(MAKE) -C audio distclean
|
||||||
|
|
3
tools/com-plugin/.gitignore
vendored
Normal file
3
tools/com-plugin/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
*.d
|
||||||
|
*.o
|
||||||
|
*.so
|
12
tools/com-plugin/.gitrepo
Normal file
12
tools/com-plugin/.gitrepo
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
; DO NOT EDIT (unless you know what you are doing)
|
||||||
|
;
|
||||||
|
; This subdirectory is a git "subrepo", and this file is maintained by the
|
||||||
|
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
|
||||||
|
;
|
||||||
|
[subrepo]
|
||||||
|
remote = git@github.com:Thar0/com-plugin.git
|
||||||
|
branch = main
|
||||||
|
commit = 81595ed1ca40d22846064537ba5fa8147b9f7068
|
||||||
|
parent = a1632bcbfc04672f21866f11bf074b420dea9693
|
||||||
|
method = merge
|
||||||
|
cmdver = 0.4.6
|
674
tools/com-plugin/LICENSE
Normal file
674
tools/com-plugin/LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
19
tools/com-plugin/Makefile
Normal file
19
tools/com-plugin/Makefile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
TARGET := common-plugin.so
|
||||||
|
SOURCES := plugin.c
|
||||||
|
|
||||||
|
CC := gcc
|
||||||
|
CFLAGS := -Wall -Wextra -std=gnu11 -O2 -fPIC -DHAVE_STDINT_H
|
||||||
|
|
||||||
|
DEP_FILES := $(TARGET:.so=.d)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(TARGET) $(DEP_FILES)
|
||||||
|
|
||||||
|
$(TARGET): $(SOURCES)
|
||||||
|
$(CC) -shared $(CFLAGS) -MMD -o $@ $^
|
||||||
|
|
||||||
|
-include $(DEP_FILES)
|
31
tools/com-plugin/README.md
Normal file
31
tools/com-plugin/README.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# COMMON symbol ordering linker plugin
|
||||||
|
|
||||||
|
This repository contains a plugin for linkers that support the External Linker Plugin API that allows providing a manual specification for COMMON symbol ordering, intended to support matching decompilations that must reproduce an order for COMMON symbols whose names are unknown. Currently only 32-bit Big-Endian MIPS ELF object files are supported.
|
||||||
|
|
||||||
|
## How it works
|
||||||
|
|
||||||
|
The plugin expects a symbol order txt file listing the COMMON symbols in order on each line. The plugin searches each input file for the symbol definitions for these and emits a new ELF file containing BSS definitions for each COMMON symbol found with the appropriate size and alignment. This ELF file is then added as an extra input file to the linker, overriding the COMMON definitions in the other input files.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Add `-plugin common-plugin.so -plugin-opt order=bss_order.txt` to the linker invocation, replacing `bss_order.txt` with an alternative path if desired.
|
||||||
|
|
||||||
|
Also add any bss output files mentioned in the order file to the linker script (e.g. `bss.o` would be added as `*bss.o(.bss*)`) so that the additional input file is not discarded, if required.
|
||||||
|
|
||||||
|
### **Symbol order file syntax**
|
||||||
|
|
||||||
|
```
|
||||||
|
<ofile> {
|
||||||
|
<sym1>;
|
||||||
|
<sym2>;
|
||||||
|
<sym3>;
|
||||||
|
[...]
|
||||||
|
}
|
||||||
|
[...]
|
||||||
|
```
|
||||||
|
|
||||||
|
The order file supports 2 styles of single-line comments (`//` and `#`) and C-style multi-line comments and ignores whitespace.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
Run `make` to build `common-plugin.so`.
|
3148
tools/com-plugin/elf.h
Normal file
3148
tools/com-plugin/elf.h
Normal file
File diff suppressed because it is too large
Load diff
67
tools/com-plugin/endian.h
Normal file
67
tools/com-plugin/endian.h
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#ifndef ENDIAN_H
|
||||||
|
#define ENDIAN_H
|
||||||
|
|
||||||
|
#if defined(__linux__) || defined(__CYGWIN__)
|
||||||
|
#include <endian.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <libkern/OSByteOrder.h>
|
||||||
|
|
||||||
|
#define htobe16(x) OSSwapHostToBigInt16(x)
|
||||||
|
#define htole16(x) OSSwapHostToLittleInt16(x)
|
||||||
|
#define be16toh(x) OSSwapBigToHostInt16(x)
|
||||||
|
#define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||||
|
|
||||||
|
#define htobe32(x) OSSwapHostToBigInt32(x)
|
||||||
|
#define htole32(x) OSSwapHostToLittleInt32(x)
|
||||||
|
#define be32toh(x) OSSwapBigToHostInt32(x)
|
||||||
|
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||||
|
|
||||||
|
#define htobe64(x) OSSwapHostToBigInt64(x)
|
||||||
|
#define htole64(x) OSSwapHostToLittleInt64(x)
|
||||||
|
#define be64toh(x) OSSwapBigToHostInt64(x)
|
||||||
|
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if !defined(__BYTE_ORDER__)
|
||||||
|
#error "No endian define provided by compiler"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||||
|
|
||||||
|
#define htobe16(x) (x)
|
||||||
|
#define htole16(x) __builtin_bswap16(x)
|
||||||
|
#define be16toh(x) (x)
|
||||||
|
#define le16toh(x) __builtin_bswap16(x)
|
||||||
|
|
||||||
|
#define htobe32(x) (x)
|
||||||
|
#define htole32(x) __builtin_bswap32(x)
|
||||||
|
#define be32toh(x) (x)
|
||||||
|
#define le32toh(x) __builtin_bswap32(x)
|
||||||
|
|
||||||
|
#define htobe64(x) (x)
|
||||||
|
#define htole64(x) __builtin_bswap64(x)
|
||||||
|
#define be64toh(x) (x)
|
||||||
|
#define le64toh(x) __builtin_bswap64(x)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define htobe16(x) __builtin_bswap16(x)
|
||||||
|
#define htole16(x) (x)
|
||||||
|
#define be16toh(x) __builtin_bswap16(x)
|
||||||
|
#define le16toh(x) (x)
|
||||||
|
|
||||||
|
#define htobe32(x) __builtin_bswap32(x)
|
||||||
|
#define htole32(x) (x)
|
||||||
|
#define be32toh(x) __builtin_bswap32(x)
|
||||||
|
#define le32toh(x) (x)
|
||||||
|
|
||||||
|
#define htobe64(x) __builtin_bswap64(x)
|
||||||
|
#define htole64(x) (x)
|
||||||
|
#define be64toh(x) __builtin_bswap64(x)
|
||||||
|
#define le64toh(x) (x)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
622
tools/com-plugin/plugin-api.h
Normal file
622
tools/com-plugin/plugin-api.h
Normal file
|
@ -0,0 +1,622 @@
|
||||||
|
/* plugin-api.h -- External linker plugin API. */
|
||||||
|
|
||||||
|
/* Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||||
|
Written by Cary Coutant <ccoutant@google.com>.
|
||||||
|
|
||||||
|
This file is part of binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||||
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
/* This file defines the interface for writing a linker plugin, which is
|
||||||
|
described at < http://gcc.gnu.org/wiki/whopr/driver >. */
|
||||||
|
|
||||||
|
#ifndef PLUGIN_API_H
|
||||||
|
#define PLUGIN_API_H
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
#elif defined(HAVE_INTTYPES_H)
|
||||||
|
#include <inttypes.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && \
|
||||||
|
!defined(UINT64_MAX) && !defined(uint64_t)
|
||||||
|
#error cannot find uint64_t type
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Detect endianess based on gcc's (>=4.6.0) __BYTE_ORDER__ macro. */
|
||||||
|
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
|
||||||
|
defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_PDP_ENDIAN__)
|
||||||
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
|
#define PLUGIN_LITTLE_ENDIAN 1
|
||||||
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
|
#define PLUGIN_BIG_ENDIAN 1
|
||||||
|
#elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
|
||||||
|
#define PLUGIN_PDP_ENDIAN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* Include header files to define endian macros. */
|
||||||
|
#if defined(__GLIBC__) || defined(__GNU_LIBRARY__) || defined(__ANDROID__)
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
|
#elif defined(__SVR4) && defined(__sun)
|
||||||
|
#include <sys/byteorder.h>
|
||||||
|
|
||||||
|
#elif defined(__FreeBSD__) || defined(__NetBSD__) || \
|
||||||
|
defined(__DragonFly__) || defined(__minix)
|
||||||
|
#include <sys/endian.h>
|
||||||
|
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
#include <machine/endian.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Detect endianess based on __BYTE_ORDER. */
|
||||||
|
#ifdef __BYTE_ORDER
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
#define PLUGIN_LITTLE_ENDIAN 1
|
||||||
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
#define PLUGIN_BIG_ENDIAN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Detect endianess based on _BYTE_ORDER. */
|
||||||
|
#elif defined _BYTE_ORDER
|
||||||
|
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||||
|
#define PLUGIN_LITTLE_ENDIAN 1
|
||||||
|
#elif _BYTE_ORDER == _BIG_ENDIAN
|
||||||
|
#define PLUGIN_BIG_ENDIAN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Detect based on _WIN32. */
|
||||||
|
#elif defined _WIN32
|
||||||
|
#define PLUGIN_LITTLE_ENDIAN 1
|
||||||
|
|
||||||
|
/* Detect based on __BIG_ENDIAN__ and __LITTLE_ENDIAN__ */
|
||||||
|
#elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN
|
||||||
|
#define PLUGIN_LITTLE_ENDIAN 1
|
||||||
|
#elif defined __BIG_ENDIAN__ || defined _BIG_ENDIAN
|
||||||
|
#define PLUGIN_BIG_ENDIAN 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Status code returned by most API routines. */
|
||||||
|
|
||||||
|
enum ld_plugin_status
|
||||||
|
{
|
||||||
|
LDPS_OK = 0,
|
||||||
|
LDPS_NO_SYMS, /* Attempt to get symbols that haven't been added. */
|
||||||
|
LDPS_BAD_HANDLE, /* No claimed object associated with given handle. */
|
||||||
|
LDPS_ERR
|
||||||
|
/* Additional Error codes TBD. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The version of the API specification. */
|
||||||
|
|
||||||
|
enum ld_plugin_api_version
|
||||||
|
{
|
||||||
|
LD_PLUGIN_API_VERSION = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The type of output file being generated by the linker. */
|
||||||
|
|
||||||
|
enum ld_plugin_output_file_type
|
||||||
|
{
|
||||||
|
LDPO_REL,
|
||||||
|
LDPO_EXEC,
|
||||||
|
LDPO_DYN,
|
||||||
|
LDPO_PIE
|
||||||
|
};
|
||||||
|
|
||||||
|
/* An input file managed by the plugin library. */
|
||||||
|
|
||||||
|
struct ld_plugin_input_file
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int fd;
|
||||||
|
off_t offset;
|
||||||
|
off_t filesize;
|
||||||
|
void *handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* A symbol belonging to an input file managed by the plugin library. */
|
||||||
|
|
||||||
|
struct ld_plugin_symbol
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
char *version;
|
||||||
|
/* This is for compatibility with older ABIs. The older ABI defined
|
||||||
|
only 'def' field. */
|
||||||
|
#if PLUGIN_BIG_ENDIAN == 1
|
||||||
|
char unused;
|
||||||
|
char section_kind;
|
||||||
|
char symbol_type;
|
||||||
|
char def;
|
||||||
|
#elif PLUGIN_LITTLE_ENDIAN == 1
|
||||||
|
char def;
|
||||||
|
char symbol_type;
|
||||||
|
char section_kind;
|
||||||
|
char unused;
|
||||||
|
#elif PLUGIN_PDP_ENDIAN == 1
|
||||||
|
char symbol_type;
|
||||||
|
char def;
|
||||||
|
char unused;
|
||||||
|
char section_kind;
|
||||||
|
#else
|
||||||
|
#error "Could not detect architecture endianess"
|
||||||
|
#endif
|
||||||
|
int visibility;
|
||||||
|
uint64_t size;
|
||||||
|
char *comdat_key;
|
||||||
|
int resolution;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* An object's section. */
|
||||||
|
|
||||||
|
struct ld_plugin_section
|
||||||
|
{
|
||||||
|
const void* handle;
|
||||||
|
unsigned int shndx;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Whether the symbol is a definition, reference, or common, weak or not. */
|
||||||
|
|
||||||
|
enum ld_plugin_symbol_kind
|
||||||
|
{
|
||||||
|
LDPK_DEF,
|
||||||
|
LDPK_WEAKDEF,
|
||||||
|
LDPK_UNDEF,
|
||||||
|
LDPK_WEAKUNDEF,
|
||||||
|
LDPK_COMMON
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The visibility of the symbol. */
|
||||||
|
|
||||||
|
enum ld_plugin_symbol_visibility
|
||||||
|
{
|
||||||
|
LDPV_DEFAULT,
|
||||||
|
LDPV_PROTECTED,
|
||||||
|
LDPV_INTERNAL,
|
||||||
|
LDPV_HIDDEN
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The type of the symbol. */
|
||||||
|
|
||||||
|
enum ld_plugin_symbol_type
|
||||||
|
{
|
||||||
|
LDST_UNKNOWN,
|
||||||
|
LDST_FUNCTION,
|
||||||
|
LDST_VARIABLE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ld_plugin_symbol_section_kind
|
||||||
|
{
|
||||||
|
LDSSK_DEFAULT,
|
||||||
|
LDSSK_BSS
|
||||||
|
};
|
||||||
|
|
||||||
|
/* How a symbol is resolved. */
|
||||||
|
|
||||||
|
enum ld_plugin_symbol_resolution
|
||||||
|
{
|
||||||
|
LDPR_UNKNOWN = 0,
|
||||||
|
|
||||||
|
/* Symbol is still undefined at this point. */
|
||||||
|
LDPR_UNDEF,
|
||||||
|
|
||||||
|
/* This is the prevailing definition of the symbol, with references from
|
||||||
|
regular object code. */
|
||||||
|
LDPR_PREVAILING_DEF,
|
||||||
|
|
||||||
|
/* This is the prevailing definition of the symbol, with no
|
||||||
|
references from regular objects. It is only referenced from IR
|
||||||
|
code. */
|
||||||
|
LDPR_PREVAILING_DEF_IRONLY,
|
||||||
|
|
||||||
|
/* This definition was pre-empted by a definition in a regular
|
||||||
|
object file. */
|
||||||
|
LDPR_PREEMPTED_REG,
|
||||||
|
|
||||||
|
/* This definition was pre-empted by a definition in another IR file. */
|
||||||
|
LDPR_PREEMPTED_IR,
|
||||||
|
|
||||||
|
/* This symbol was resolved by a definition in another IR file. */
|
||||||
|
LDPR_RESOLVED_IR,
|
||||||
|
|
||||||
|
/* This symbol was resolved by a definition in a regular object
|
||||||
|
linked into the main executable. */
|
||||||
|
LDPR_RESOLVED_EXEC,
|
||||||
|
|
||||||
|
/* This symbol was resolved by a definition in a shared object. */
|
||||||
|
LDPR_RESOLVED_DYN,
|
||||||
|
|
||||||
|
/* This is the prevailing definition of the symbol, with no
|
||||||
|
references from regular objects. It is only referenced from IR
|
||||||
|
code, but the symbol is exported and may be referenced from
|
||||||
|
a dynamic object (not seen at link time). */
|
||||||
|
LDPR_PREVAILING_DEF_IRONLY_EXP
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The plugin library's "claim file" handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_claim_file_handler) (
|
||||||
|
const struct ld_plugin_input_file *file, int *claimed);
|
||||||
|
|
||||||
|
/* The plugin library's "claim file" handler, version 2. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_claim_file_handler_v2) (
|
||||||
|
const struct ld_plugin_input_file *file, int *claimed, int known_used);
|
||||||
|
|
||||||
|
/* The plugin library's "all symbols read" handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_all_symbols_read_handler) (void);
|
||||||
|
|
||||||
|
/* The plugin library's cleanup handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_cleanup_handler) (void);
|
||||||
|
|
||||||
|
/* The linker's interface for registering the "claim file" handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_register_claim_file) (ld_plugin_claim_file_handler handler);
|
||||||
|
|
||||||
|
/* The linker's interface for registering the "claim file" handler,
|
||||||
|
version 2. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_register_claim_file_v2) (ld_plugin_claim_file_handler_v2 handler);
|
||||||
|
|
||||||
|
/* The linker's interface for registering the "all symbols read" handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_register_all_symbols_read) (
|
||||||
|
ld_plugin_all_symbols_read_handler handler);
|
||||||
|
|
||||||
|
/* The linker's interface for registering the cleanup handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_register_cleanup) (ld_plugin_cleanup_handler handler);
|
||||||
|
|
||||||
|
/* The linker's interface for adding symbols from a claimed input file. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_add_symbols) (void *handle, int nsyms,
|
||||||
|
const struct ld_plugin_symbol *syms);
|
||||||
|
|
||||||
|
/* The linker's interface for getting the input file information with
|
||||||
|
an open (possibly re-opened) file descriptor. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_input_file) (const void *handle,
|
||||||
|
struct ld_plugin_input_file *file);
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_view) (const void *handle, const void **viewp);
|
||||||
|
|
||||||
|
/* The linker's interface for releasing the input file. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_release_input_file) (const void *handle);
|
||||||
|
|
||||||
|
/* The linker's interface for retrieving symbol resolution information. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_symbols) (const void *handle, int nsyms,
|
||||||
|
struct ld_plugin_symbol *syms);
|
||||||
|
|
||||||
|
/* The linker's interface for adding a compiled input file. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_add_input_file) (const char *pathname);
|
||||||
|
|
||||||
|
/* The linker's interface for adding a library that should be searched. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_add_input_library) (const char *libname);
|
||||||
|
|
||||||
|
/* The linker's interface for adding a library path that should be searched. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_set_extra_library_path) (const char *path);
|
||||||
|
|
||||||
|
/* The linker's interface for issuing a warning or error message. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_message) (int level, const char *format, ...);
|
||||||
|
|
||||||
|
/* The linker's interface for retrieving the number of sections in an object.
|
||||||
|
The handle is obtained in the claim_file handler. This interface should
|
||||||
|
only be invoked in the claim_file handler. This function sets *COUNT to
|
||||||
|
the number of sections in the object. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_input_section_count) (const void* handle, unsigned int *count);
|
||||||
|
|
||||||
|
/* The linker's interface for retrieving the section type of a specific
|
||||||
|
section in an object. This interface should only be invoked in the
|
||||||
|
claim_file handler. This function sets *TYPE to an ELF SHT_xxx value. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_input_section_type) (const struct ld_plugin_section section,
|
||||||
|
unsigned int *type);
|
||||||
|
|
||||||
|
/* The linker's interface for retrieving the name of a specific section in
|
||||||
|
an object. This interface should only be invoked in the claim_file handler.
|
||||||
|
This function sets *SECTION_NAME_PTR to a null-terminated buffer allocated
|
||||||
|
by malloc. The plugin must free *SECTION_NAME_PTR. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_input_section_name) (const struct ld_plugin_section section,
|
||||||
|
char **section_name_ptr);
|
||||||
|
|
||||||
|
/* The linker's interface for retrieving the contents of a specific section
|
||||||
|
in an object. This interface should only be invoked in the claim_file
|
||||||
|
handler. This function sets *SECTION_CONTENTS to point to a buffer that is
|
||||||
|
valid until clam_file handler returns. It sets *LEN to the size of the
|
||||||
|
buffer. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_input_section_contents) (const struct ld_plugin_section section,
|
||||||
|
const unsigned char **section_contents,
|
||||||
|
size_t* len);
|
||||||
|
|
||||||
|
/* The linker's interface for specifying the desired order of sections.
|
||||||
|
The sections should be specifed using the array SECTION_LIST in the
|
||||||
|
order in which they should appear in the final layout. NUM_SECTIONS
|
||||||
|
specifies the number of entries in each array. This should be invoked
|
||||||
|
in the all_symbols_read handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_update_section_order) (const struct ld_plugin_section *section_list,
|
||||||
|
unsigned int num_sections);
|
||||||
|
|
||||||
|
/* The linker's interface for specifying that reordering of sections is
|
||||||
|
desired so that the linker can prepare for it. This should be invoked
|
||||||
|
before update_section_order, preferably in the claim_file handler. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_allow_section_ordering) (void);
|
||||||
|
|
||||||
|
/* The linker's interface for specifying that a subset of sections is
|
||||||
|
to be mapped to a unique segment. If the plugin wants to call
|
||||||
|
unique_segment_for_sections, it must call this function from a
|
||||||
|
claim_file_handler or when it is first loaded. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_allow_unique_segment_for_sections) (void);
|
||||||
|
|
||||||
|
/* The linker's interface for specifying that a specific set of sections
|
||||||
|
must be mapped to a unique segment. ELF segments do not have names
|
||||||
|
and the NAME is used as the name of the newly created output section
|
||||||
|
that is then placed in the unique PT_LOAD segment. FLAGS is used to
|
||||||
|
specify if any additional segment flags need to be set. For instance,
|
||||||
|
a specific segment flag can be set to identify this segment. Unsetting
|
||||||
|
segment flags that would be set by default is not possible. The
|
||||||
|
parameter SEGMENT_ALIGNMENT when non-zero will override the default. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_unique_segment_for_sections) (
|
||||||
|
const char* segment_name,
|
||||||
|
uint64_t segment_flags,
|
||||||
|
uint64_t segment_alignment,
|
||||||
|
const struct ld_plugin_section * section_list,
|
||||||
|
unsigned int num_sections);
|
||||||
|
|
||||||
|
/* The linker's interface for retrieving the section alignment requirement
|
||||||
|
of a specific section in an object. This interface should only be invoked in the
|
||||||
|
claim_file handler. This function sets *ADDRALIGN to the ELF sh_addralign
|
||||||
|
value of the input section. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_input_section_alignment) (const struct ld_plugin_section section,
|
||||||
|
unsigned int *addralign);
|
||||||
|
|
||||||
|
/* The linker's interface for retrieving the section size of a specific section
|
||||||
|
in an object. This interface should only be invoked in the claim_file handler.
|
||||||
|
This function sets *SECSIZE to the ELF sh_size
|
||||||
|
value of the input section. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_input_section_size) (const struct ld_plugin_section section,
|
||||||
|
uint64_t *secsize);
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_new_input_handler) (const struct ld_plugin_input_file *file);
|
||||||
|
|
||||||
|
/* The linker's interface for registering the "new_input" handler. This handler
|
||||||
|
will be notified when a new input file has been added after the
|
||||||
|
all_symbols_read event, allowing the plugin to, for example, set a unique
|
||||||
|
segment for sections in plugin-generated input files. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_register_new_input) (ld_plugin_new_input_handler handler);
|
||||||
|
|
||||||
|
/* The linker's interface for getting the list of wrapped symbols using the
|
||||||
|
--wrap option. This sets *NUM_SYMBOLS to number of wrapped symbols and
|
||||||
|
*WRAP_SYMBOL_LIST to the list of wrapped symbols. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_get_wrap_symbols) (uint64_t *num_symbols,
|
||||||
|
const char ***wrap_symbol_list);
|
||||||
|
|
||||||
|
enum ld_plugin_level
|
||||||
|
{
|
||||||
|
LDPL_INFO,
|
||||||
|
LDPL_WARNING,
|
||||||
|
LDPL_ERROR,
|
||||||
|
LDPL_FATAL
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Contract between a plug-in and a linker. */
|
||||||
|
|
||||||
|
enum linker_api_version
|
||||||
|
{
|
||||||
|
/* The linker/plugin do not implement any of the API levels below, the API
|
||||||
|
is determined solely via the transfer vector. */
|
||||||
|
LAPI_V0,
|
||||||
|
|
||||||
|
/* API level v1. The linker provides get_symbols_v3, add_symbols_v2,
|
||||||
|
the plugin will use that and not any lower versions.
|
||||||
|
claim_file is thread-safe on the plugin side and
|
||||||
|
add_symbols on the linker side. */
|
||||||
|
LAPI_V1
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The linker's interface for API version negotiation. A plug-in calls
|
||||||
|
the function (with its IDENTIFIER and VERSION), plus minimal and maximal
|
||||||
|
version of linker_api_version is provided. Linker then returns selected
|
||||||
|
API version and provides its IDENTIFIER and VERSION. The returned value
|
||||||
|
by linker must be in range [MINIMAL_API_SUPPORTED, MAXIMAL_API_SUPPORTED].
|
||||||
|
Identifier pointers remain valid as long as the plugin is loaded. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
int
|
||||||
|
(*ld_plugin_get_api_version) (const char *plugin_identifier,
|
||||||
|
const char *plugin_version,
|
||||||
|
int minimal_api_supported,
|
||||||
|
int maximal_api_supported,
|
||||||
|
const char **linker_identifier,
|
||||||
|
const char **linker_version);
|
||||||
|
|
||||||
|
/* Values for the tv_tag field of the transfer vector. */
|
||||||
|
|
||||||
|
enum ld_plugin_tag
|
||||||
|
{
|
||||||
|
LDPT_NULL,
|
||||||
|
LDPT_API_VERSION,
|
||||||
|
LDPT_GOLD_VERSION,
|
||||||
|
LDPT_LINKER_OUTPUT,
|
||||||
|
LDPT_OPTION,
|
||||||
|
LDPT_REGISTER_CLAIM_FILE_HOOK,
|
||||||
|
LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK,
|
||||||
|
LDPT_REGISTER_CLEANUP_HOOK,
|
||||||
|
LDPT_ADD_SYMBOLS,
|
||||||
|
LDPT_GET_SYMBOLS,
|
||||||
|
LDPT_ADD_INPUT_FILE,
|
||||||
|
LDPT_MESSAGE,
|
||||||
|
LDPT_GET_INPUT_FILE,
|
||||||
|
LDPT_RELEASE_INPUT_FILE,
|
||||||
|
LDPT_ADD_INPUT_LIBRARY,
|
||||||
|
LDPT_OUTPUT_NAME,
|
||||||
|
LDPT_SET_EXTRA_LIBRARY_PATH,
|
||||||
|
LDPT_GNU_LD_VERSION,
|
||||||
|
LDPT_GET_VIEW,
|
||||||
|
LDPT_GET_INPUT_SECTION_COUNT,
|
||||||
|
LDPT_GET_INPUT_SECTION_TYPE,
|
||||||
|
LDPT_GET_INPUT_SECTION_NAME,
|
||||||
|
LDPT_GET_INPUT_SECTION_CONTENTS,
|
||||||
|
LDPT_UPDATE_SECTION_ORDER,
|
||||||
|
LDPT_ALLOW_SECTION_ORDERING,
|
||||||
|
LDPT_GET_SYMBOLS_V2,
|
||||||
|
LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS,
|
||||||
|
LDPT_UNIQUE_SEGMENT_FOR_SECTIONS,
|
||||||
|
LDPT_GET_SYMBOLS_V3,
|
||||||
|
LDPT_GET_INPUT_SECTION_ALIGNMENT,
|
||||||
|
LDPT_GET_INPUT_SECTION_SIZE,
|
||||||
|
LDPT_REGISTER_NEW_INPUT_HOOK,
|
||||||
|
LDPT_GET_WRAP_SYMBOLS,
|
||||||
|
LDPT_ADD_SYMBOLS_V2,
|
||||||
|
LDPT_GET_API_VERSION,
|
||||||
|
LDPT_REGISTER_CLAIM_FILE_HOOK_V2
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The plugin transfer vector. */
|
||||||
|
|
||||||
|
struct ld_plugin_tv
|
||||||
|
{
|
||||||
|
enum ld_plugin_tag tv_tag;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
int tv_val;
|
||||||
|
const char *tv_string;
|
||||||
|
ld_plugin_register_claim_file tv_register_claim_file;
|
||||||
|
ld_plugin_register_claim_file_v2 tv_register_claim_file_v2;
|
||||||
|
ld_plugin_register_all_symbols_read tv_register_all_symbols_read;
|
||||||
|
ld_plugin_register_cleanup tv_register_cleanup;
|
||||||
|
ld_plugin_add_symbols tv_add_symbols;
|
||||||
|
ld_plugin_get_symbols tv_get_symbols;
|
||||||
|
ld_plugin_add_input_file tv_add_input_file;
|
||||||
|
ld_plugin_message tv_message;
|
||||||
|
ld_plugin_get_input_file tv_get_input_file;
|
||||||
|
ld_plugin_get_view tv_get_view;
|
||||||
|
ld_plugin_release_input_file tv_release_input_file;
|
||||||
|
ld_plugin_add_input_library tv_add_input_library;
|
||||||
|
ld_plugin_set_extra_library_path tv_set_extra_library_path;
|
||||||
|
ld_plugin_get_input_section_count tv_get_input_section_count;
|
||||||
|
ld_plugin_get_input_section_type tv_get_input_section_type;
|
||||||
|
ld_plugin_get_input_section_name tv_get_input_section_name;
|
||||||
|
ld_plugin_get_input_section_contents tv_get_input_section_contents;
|
||||||
|
ld_plugin_update_section_order tv_update_section_order;
|
||||||
|
ld_plugin_allow_section_ordering tv_allow_section_ordering;
|
||||||
|
ld_plugin_allow_unique_segment_for_sections tv_allow_unique_segment_for_sections;
|
||||||
|
ld_plugin_unique_segment_for_sections tv_unique_segment_for_sections;
|
||||||
|
ld_plugin_get_input_section_alignment tv_get_input_section_alignment;
|
||||||
|
ld_plugin_get_input_section_size tv_get_input_section_size;
|
||||||
|
ld_plugin_register_new_input tv_register_new_input;
|
||||||
|
ld_plugin_get_wrap_symbols tv_get_wrap_symbols;
|
||||||
|
ld_plugin_get_api_version tv_get_api_version;
|
||||||
|
} tv_u;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The plugin library's "onload" entry point. */
|
||||||
|
|
||||||
|
typedef
|
||||||
|
enum ld_plugin_status
|
||||||
|
(*ld_plugin_onload) (struct ld_plugin_tv *tv);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !defined(PLUGIN_API_H) */
|
831
tools/com-plugin/plugin.c
Normal file
831
tools/com-plugin/plugin.c
Normal file
|
@ -0,0 +1,831 @@
|
||||||
|
/**
|
||||||
|
* COMMON symbol ordering plugin for linkers supporting the External Linker Plugin API.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 Tharo
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "endian.h"
|
||||||
|
#include "elf.h"
|
||||||
|
#include "plugin-api.h"
|
||||||
|
|
||||||
|
#define ELF32_IDENT_VALID(ehdr) \
|
||||||
|
((ehdr)->e_ident[EI_MAG0] == ELFMAG0 && (ehdr)->e_ident[EI_MAG1] == ELFMAG1 && \
|
||||||
|
(ehdr)->e_ident[EI_MAG2] == ELFMAG2 && (ehdr)->e_ident[EI_MAG3] == ELFMAG3)
|
||||||
|
|
||||||
|
#define ELF32_IS_32(ehdr) ((ehdr)->e_ident[EI_CLASS] == ELFCLASS32)
|
||||||
|
|
||||||
|
#define ELF32_IS_BE(ehdr) ((ehdr)->e_ident[EI_DATA] == ELFDATA2MSB)
|
||||||
|
|
||||||
|
#define iswhitespace(c) (isblank(c) || ((c) == '\n'))
|
||||||
|
|
||||||
|
#define GLUE2(a,b) a##b
|
||||||
|
#define GLUE(a,b) GLUE2(a,b)
|
||||||
|
#define ARRLEN(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
|
||||||
|
#define BITSET_TYPE uint64_t
|
||||||
|
#define BITSET_MASK (8 * sizeof(BITSET_TYPE) - 1)
|
||||||
|
#define BITSET_SHIFT (__builtin_ctz((uint32_t)~BITSET_MASK))
|
||||||
|
#define BITSET_SIZE_BYTES(n) ((((n) + 8 * sizeof(BITSET_TYPE) - 1) & ~(8 * sizeof(BITSET_TYPE) - 1)) >> 3)
|
||||||
|
#define BITSET_ALLOC(size) calloc(1, BITSET_SIZE_BYTES(size))
|
||||||
|
#define BITSET_FREE(set) free(set)
|
||||||
|
#define BITSET_GET(set, key) ((set)[(key) >> BITSET_SHIFT] & ((BITSET_TYPE)1 << ((key) & BITSET_MASK)))
|
||||||
|
#define BITSET_SET(set, key) ((set)[(key) >> BITSET_SHIFT] |= ((BITSET_TYPE)1 << ((key) & BITSET_MASK)))
|
||||||
|
|
||||||
|
#define strequ(s1, s2const) (strncmp(s1, s2const, sizeof(s2const) - 1) == 0)
|
||||||
|
|
||||||
|
struct bss_ofile {
|
||||||
|
char *path;
|
||||||
|
size_t num_symbols;
|
||||||
|
char **symbol_names;
|
||||||
|
Elf32_Sym *symbols;
|
||||||
|
BITSET_TYPE *symbols_found;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
// Our state
|
||||||
|
char *string_pool;
|
||||||
|
struct bss_ofile *ofiles;
|
||||||
|
size_t num_ofiles;
|
||||||
|
// Our options
|
||||||
|
char *order_path;
|
||||||
|
// LD plugin
|
||||||
|
int api_version;
|
||||||
|
int gnu_ld_version;
|
||||||
|
int linker_output;
|
||||||
|
const char *output_name;
|
||||||
|
ld_plugin_message message;
|
||||||
|
ld_plugin_add_symbols add_symbols;
|
||||||
|
ld_plugin_get_symbols get_symbols;
|
||||||
|
ld_plugin_get_symbols get_symbols_v2;
|
||||||
|
ld_plugin_add_input_file add_input_file;
|
||||||
|
ld_plugin_get_input_file get_input_file;
|
||||||
|
ld_plugin_register_cleanup register_cleanup;
|
||||||
|
ld_plugin_register_claim_file register_claim_file;
|
||||||
|
ld_plugin_register_all_symbols_read register_all_symbols_read;
|
||||||
|
} pl;
|
||||||
|
|
||||||
|
#define ltell(fd) lseek((fd), 0, SEEK_CUR)
|
||||||
|
|
||||||
|
static int read_s_(int fd, void *buf, size_t nbyte, int line)
|
||||||
|
{
|
||||||
|
ssize_t result = read(fd, buf, nbyte);
|
||||||
|
if ((size_t)result != nbyte) {
|
||||||
|
pl.message(LDPL_FATAL, "[%d] Could not read %lu bytes from input file [%ld]", line, nbyte, result);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#define read_s(fd, buf, nbyte) \
|
||||||
|
do { if (read_s_(fd, buf, nbyte, __LINE__)) return LDPS_ERR; } while (0)
|
||||||
|
|
||||||
|
#define SEEKF(file, pos) \
|
||||||
|
lseek((file)->fd, (file)->offset + (pos), SEEK_SET)
|
||||||
|
|
||||||
|
#define WITH_NEW_FILE_POS(file, pos) \
|
||||||
|
for (off_t GLUE(_o_,__LINE__) = ltell((file)->fd),GLUE(_b_,__LINE__)=(SEEKF(file, pos), 1); \
|
||||||
|
GLUE(_b_,__LINE__); \
|
||||||
|
GLUE(_b_,__LINE__)=0,lseek((file)->fd, GLUE(_o_,__LINE__), SEEK_SET))
|
||||||
|
|
||||||
|
static bool
|
||||||
|
elf_syms_equal(Elf32_Sym *sym1, Elf32_Sym *sym2)
|
||||||
|
{
|
||||||
|
return (sym1->st_value == sym2->st_value) &&
|
||||||
|
(sym1->st_size == sym2->st_size) &&
|
||||||
|
(sym1->st_info == sym2->st_info) &&
|
||||||
|
(sym1->st_other == sym2->st_other) &&
|
||||||
|
(sym1->st_shndx == sym2->st_shndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum ld_plugin_status
|
||||||
|
claim_file(const struct ld_plugin_input_file *file, int *claimed)
|
||||||
|
{
|
||||||
|
*claimed = false;
|
||||||
|
|
||||||
|
// Read the input file for COMMON symbol definitions
|
||||||
|
// The input is assumed to be a Big-Endian 32-bit ELF file
|
||||||
|
|
||||||
|
bool error = false;
|
||||||
|
|
||||||
|
WITH_NEW_FILE_POS(file, 0) {
|
||||||
|
Elf32_Ehdr ehdr;
|
||||||
|
read_s(file->fd, &ehdr, sizeof(ehdr));
|
||||||
|
|
||||||
|
if (!ELF32_IDENT_VALID(&ehdr) || !ELF32_IS_32(&ehdr) || !ELF32_IS_BE(&ehdr)) {
|
||||||
|
pl.message(LDPL_FATAL, "Input file %s is not a 32-bit Big-Endian ELF file", file->name);
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t e_shoff = be32toh(ehdr.e_shoff);
|
||||||
|
uint16_t e_shentsize = be16toh(ehdr.e_shentsize);
|
||||||
|
uint16_t e_shnum = be16toh(ehdr.e_shnum);
|
||||||
|
|
||||||
|
if (e_shentsize != sizeof(Elf32_Shdr)) {
|
||||||
|
pl.message(LDPL_FATAL, "e_shentsize unexpected size");
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Elf32_Shdr strtab;
|
||||||
|
char *strtab_data = NULL;
|
||||||
|
size_t last_strtab_ind = (size_t)-1;
|
||||||
|
|
||||||
|
// Look for symbol tables to search for COMMON symbols in
|
||||||
|
SEEKF(file, e_shoff);
|
||||||
|
for (size_t i = 0; i < e_shnum; i++) {
|
||||||
|
Elf32_Shdr shdr;
|
||||||
|
read_s(file->fd, &shdr, sizeof(shdr));
|
||||||
|
|
||||||
|
uint32_t sh_type = be32toh(shdr.sh_type);
|
||||||
|
|
||||||
|
if (sh_type != SHT_SYMTAB)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Found a symtab
|
||||||
|
uint32_t sh_offset = be32toh(shdr.sh_offset);
|
||||||
|
uint32_t sh_size = be32toh(shdr.sh_size);
|
||||||
|
|
||||||
|
// Read strtab for this symtab, cache it
|
||||||
|
size_t strtab_ind = be32toh(shdr.sh_link);
|
||||||
|
if (strtab_ind != last_strtab_ind) {
|
||||||
|
if (strtab_data != NULL)
|
||||||
|
free(strtab_data);
|
||||||
|
|
||||||
|
// Read strtab header
|
||||||
|
WITH_NEW_FILE_POS(file, e_shoff + strtab_ind * sizeof(Elf32_Shdr)) {
|
||||||
|
read_s(file->fd, &strtab, sizeof(strtab));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read strtab contents
|
||||||
|
uint32_t strtab_offset = be32toh(strtab.sh_offset);
|
||||||
|
uint32_t strtab_size = be32toh(strtab.sh_size);
|
||||||
|
strtab_data = malloc(strtab_size);
|
||||||
|
WITH_NEW_FILE_POS(file, strtab_offset) {
|
||||||
|
read_s(file->fd, strtab_data, strtab_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_strtab_ind = strtab_ind;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read each symbol, save the COMMON symbols into a list
|
||||||
|
WITH_NEW_FILE_POS(file, sh_offset) {
|
||||||
|
size_t nsym = sh_size / sizeof(Elf32_Sym);
|
||||||
|
|
||||||
|
for (size_t j = 0; j < nsym; j++) {
|
||||||
|
Elf32_Sym elfsym;
|
||||||
|
read_s(file->fd, &elfsym, sizeof(elfsym));
|
||||||
|
|
||||||
|
if (be16toh(elfsym.st_shndx) != SHN_COMMON)
|
||||||
|
continue; // Skip non-COMMON symbols
|
||||||
|
|
||||||
|
const char *sym_name = &strtab_data[be32toh(elfsym.st_name)];
|
||||||
|
|
||||||
|
// Try to find this symbol in one of the specified bss output files
|
||||||
|
for (size_t f = 0; f < pl.num_ofiles; f++) {
|
||||||
|
struct bss_ofile *ofile = &pl.ofiles[f];
|
||||||
|
|
||||||
|
for (size_t k = 0; k < ofile->num_symbols; k++) {
|
||||||
|
if (strcmp(sym_name, ofile->symbol_names[k]) == 0) {
|
||||||
|
if (BITSET_GET(ofile->symbols_found, k)) {
|
||||||
|
// Already occupied, check equivalence
|
||||||
|
if (!elf_syms_equal(&ofile->symbols[k], &elfsym)) {
|
||||||
|
pl.message(LDPL_ERROR, "Found distinct COMMON symbols with the same name: %s",
|
||||||
|
ofile->symbol_names[k]);
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BITSET_SET(ofile->symbols_found, k);
|
||||||
|
ofile->symbols[k] = elfsym;
|
||||||
|
}
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pl.message(LDPL_WARNING,
|
||||||
|
"Found COMMON symbol %s in input file %s not mentioned in the order spec",
|
||||||
|
sym_name, file->name);
|
||||||
|
found:;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (strtab_data != NULL)
|
||||||
|
free(strtab_data);
|
||||||
|
}
|
||||||
|
return (error) ? LDPS_ERR : LDPS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum ld_plugin_status
|
||||||
|
all_symbols_read(void)
|
||||||
|
{
|
||||||
|
for (size_t f = 0; f < pl.num_ofiles; f++) {
|
||||||
|
struct bss_ofile *ofile = &pl.ofiles[f];
|
||||||
|
|
||||||
|
// Make sure we got every symbol mentioned
|
||||||
|
bool error = false;
|
||||||
|
for (size_t i = 0; i < ofile->num_symbols; i++) {
|
||||||
|
if (!BITSET_GET(ofile->symbols_found, i)) {
|
||||||
|
pl.message(LDPL_ERROR, "Did not find symbol %s mentioned in the order specification in any input file",
|
||||||
|
ofile->symbol_names[i]);
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error)
|
||||||
|
return LDPS_ERR;
|
||||||
|
|
||||||
|
// Create a dummy ELF file full of bss definitions generated from the COMMON defs and add it as an input file.
|
||||||
|
// TODO look into replacing all this with pl.add_symbols? Seems like it's not possible
|
||||||
|
// to add symbols at this stage though, since pl.add_symbols requires a file handle..
|
||||||
|
// ELF layout:
|
||||||
|
// Elf32_Ehdr ehdr
|
||||||
|
// char symbol_names[sum of name lengths]
|
||||||
|
// Elf32_Sym symbols[nsyms]
|
||||||
|
// char section_names[sum of name lengths]
|
||||||
|
// Elf32_Shdr NULL
|
||||||
|
// Elf32_Shdr .bss
|
||||||
|
// Elf32_Shdr symtab
|
||||||
|
// Elf32_Shdr strtab
|
||||||
|
// Elf32_Shdr shstrtab
|
||||||
|
|
||||||
|
FILE *elf = fopen(ofile->path, "wb");
|
||||||
|
if (elf == NULL) {
|
||||||
|
pl.message(LDPL_FATAL, "Could not open bss output file \"%s\" for writing", ofile->path);
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip the ELF header, we'll write it at the end.
|
||||||
|
fseek(elf, sizeof(Elf32_Ehdr), SEEK_SET);
|
||||||
|
|
||||||
|
// First write the strtab
|
||||||
|
uint32_t *string_offsets = malloc((2 + ofile->num_symbols) * sizeof(uint32_t));
|
||||||
|
size_t strtab_offset = ftell(elf);
|
||||||
|
size_t n = 0;
|
||||||
|
string_offsets[n++] = ftell(elf) - strtab_offset;
|
||||||
|
fprintf(elf, "%c", '\0');
|
||||||
|
string_offsets[n++] = ftell(elf) - strtab_offset;
|
||||||
|
fprintf(elf, "%s%c", ".bss", '\0');
|
||||||
|
for (size_t i = 0; i < ofile->num_symbols; i++) {
|
||||||
|
string_offsets[n++] = ftell(elf) - strtab_offset;
|
||||||
|
fprintf(elf, "%s%c", ofile->symbol_names[i], '\0');
|
||||||
|
}
|
||||||
|
size_t strtab_size = ftell(elf) - strtab_offset;
|
||||||
|
|
||||||
|
// Align to 4 for symbols
|
||||||
|
fwrite("\0\0\0\0", 4 - (ftell(elf) & 3), 1, elf);
|
||||||
|
|
||||||
|
// Record greatest alignment for the overall section alignment
|
||||||
|
size_t greatest_align = 0;
|
||||||
|
|
||||||
|
// Now write symbols
|
||||||
|
uint32_t symtab_offset = ftell(elf);
|
||||||
|
n = 0;
|
||||||
|
|
||||||
|
Elf32_Sym null_sym = {
|
||||||
|
.st_name = htobe32(string_offsets[n++]),
|
||||||
|
.st_value = 0,
|
||||||
|
.st_size = 0,
|
||||||
|
.st_info = ELF32_ST_INFO(STB_LOCAL, STT_NOTYPE),
|
||||||
|
.st_other = ELF32_ST_VISIBILITY(STV_DEFAULT),
|
||||||
|
.st_shndx = htobe16(SHN_UNDEF),
|
||||||
|
};
|
||||||
|
fwrite(&null_sym, sizeof(null_sym), 1, elf);
|
||||||
|
Elf32_Sym bss_sym = {
|
||||||
|
.st_name = htobe32(string_offsets[n++]),
|
||||||
|
.st_value = 0,
|
||||||
|
.st_size = 0,
|
||||||
|
.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION),
|
||||||
|
.st_other = ELF32_ST_VISIBILITY(STV_DEFAULT),
|
||||||
|
.st_shndx = htobe16(1), /* .bss */
|
||||||
|
};
|
||||||
|
fwrite(&bss_sym, sizeof(bss_sym), 1, elf);
|
||||||
|
|
||||||
|
size_t sym_offset = 0;
|
||||||
|
for (size_t i = 0; i < ofile->num_symbols; i++) {
|
||||||
|
Elf32_Sym *sym = &ofile->symbols[i];
|
||||||
|
uint32_t align = be32toh(sym->st_value);
|
||||||
|
sym_offset = (sym_offset + align - 1) & ~(align - 1);
|
||||||
|
|
||||||
|
if (align > greatest_align)
|
||||||
|
greatest_align = align;
|
||||||
|
|
||||||
|
Elf32_Sym outsym = {
|
||||||
|
.st_name = htobe32(string_offsets[n++]),
|
||||||
|
.st_value = htobe32(sym_offset),
|
||||||
|
.st_size = sym->st_size,
|
||||||
|
.st_info = sym->st_info,
|
||||||
|
.st_other = sym->st_other,
|
||||||
|
.st_shndx = htobe16(1), /* .bss */
|
||||||
|
};
|
||||||
|
fwrite(&outsym, sizeof(outsym), 1, elf);
|
||||||
|
|
||||||
|
sym_offset += be32toh(sym->st_size);
|
||||||
|
}
|
||||||
|
sym_offset = (sym_offset + greatest_align - 1) & ~(greatest_align - 1);
|
||||||
|
|
||||||
|
size_t symtab_size = ftell(elf) - symtab_offset;
|
||||||
|
|
||||||
|
free(string_offsets);
|
||||||
|
|
||||||
|
const uint32_t shdr_name_offsets[5] = { 0, 1, 6, 13, 20 };
|
||||||
|
size_t shstrtab_offset = ftell(elf);
|
||||||
|
// Write shstrtab
|
||||||
|
fwrite(
|
||||||
|
/* NULL [ 0] */ "\0"
|
||||||
|
/* .bss [ 1] */ ".bss\0"
|
||||||
|
/* symtab [ 6] */ "symtab\0"
|
||||||
|
/* strtab [13] */ "strtab\0"
|
||||||
|
/* shstrtab [20] */ "shstrtab\0"
|
||||||
|
/* [29] */ "\0\0\0",
|
||||||
|
32, 1, elf
|
||||||
|
);
|
||||||
|
size_t shstrtab_size = ftell(elf) - shstrtab_offset;
|
||||||
|
|
||||||
|
// We need: { NULL, .bss, symtab, strtab, shstrtab }
|
||||||
|
Elf32_Shdr shdrs[5] = {
|
||||||
|
/* NULL */ {
|
||||||
|
.sh_name = htobe32(shdr_name_offsets[0]),
|
||||||
|
.sh_type = htobe32(SHT_NULL),
|
||||||
|
.sh_flags = htobe32(0),
|
||||||
|
.sh_addr = htobe32(0x00000000),
|
||||||
|
.sh_offset = htobe32(0x00000000),
|
||||||
|
.sh_size = htobe32(0x00000000),
|
||||||
|
.sh_link = htobe32(0), /* No Link */
|
||||||
|
.sh_info = htobe32(0),
|
||||||
|
.sh_addralign = htobe32(0),
|
||||||
|
.sh_entsize = htobe32(0), /* Not a fixed-length array */
|
||||||
|
},
|
||||||
|
/* .bss */ {
|
||||||
|
.sh_name = htobe32(shdr_name_offsets[1]),
|
||||||
|
.sh_type = htobe32(SHT_NOBITS),
|
||||||
|
.sh_flags = htobe32(SHF_WRITE | SHF_ALLOC),
|
||||||
|
.sh_addr = htobe32(0x00000000),
|
||||||
|
.sh_offset = htobe32(sizeof(Elf32_Ehdr)),
|
||||||
|
.sh_size = htobe32(sym_offset),
|
||||||
|
.sh_link = htobe32(0), /* No Link */
|
||||||
|
.sh_info = htobe32(0),
|
||||||
|
.sh_addralign = htobe32(greatest_align),
|
||||||
|
.sh_entsize = htobe32(0), /* Not a fixed-length array */
|
||||||
|
},
|
||||||
|
/* symtab */ {
|
||||||
|
.sh_name = htobe32(shdr_name_offsets[2]),
|
||||||
|
.sh_type = htobe32(SHT_SYMTAB),
|
||||||
|
.sh_flags = htobe32(0),
|
||||||
|
.sh_addr = htobe32(0),
|
||||||
|
.sh_offset = htobe32(symtab_offset),
|
||||||
|
.sh_size = htobe32(symtab_size),
|
||||||
|
.sh_link = htobe32(3), /* strtab */
|
||||||
|
.sh_info = htobe32(2),
|
||||||
|
.sh_addralign = htobe32(4),
|
||||||
|
.sh_entsize = htobe32(sizeof(Elf32_Sym)),
|
||||||
|
},
|
||||||
|
/* strtab */ {
|
||||||
|
.sh_name = htobe32(shdr_name_offsets[3]),
|
||||||
|
.sh_type = htobe32(SHT_STRTAB),
|
||||||
|
.sh_flags = htobe32(0),
|
||||||
|
.sh_addr = htobe32(0),
|
||||||
|
.sh_offset = htobe32(strtab_offset),
|
||||||
|
.sh_size = htobe32(strtab_size),
|
||||||
|
.sh_link = htobe32(0), /* No Link */
|
||||||
|
.sh_info = htobe32(0),
|
||||||
|
.sh_addralign = htobe32(1),
|
||||||
|
.sh_entsize = htobe32(0), /* Not a fixed-length array */
|
||||||
|
},
|
||||||
|
/* shstrtab */ {
|
||||||
|
.sh_name = htobe32(shdr_name_offsets[4]),
|
||||||
|
.sh_type = htobe32(SHT_STRTAB),
|
||||||
|
.sh_flags = htobe32(0),
|
||||||
|
.sh_addr = htobe32(0),
|
||||||
|
.sh_offset = htobe32(shstrtab_offset),
|
||||||
|
.sh_size = htobe32(shstrtab_size),
|
||||||
|
.sh_link = htobe32(0), /* No Link */
|
||||||
|
.sh_info = htobe32(0),
|
||||||
|
.sh_addralign = htobe32(1),
|
||||||
|
.sh_entsize = htobe32(0), /* Not a fixed-length array */
|
||||||
|
},
|
||||||
|
};
|
||||||
|
size_t shdrs_offset = ftell(elf);
|
||||||
|
fwrite(shdrs, sizeof(shdrs), 1, elf);
|
||||||
|
|
||||||
|
// TODO some of these fields should change based on the properties of the input files, or even better
|
||||||
|
// it should be based on the current output format but that might not be visible to us with the limited
|
||||||
|
// plugin api...
|
||||||
|
Elf32_Ehdr ehdr = {
|
||||||
|
.e_ident = {
|
||||||
|
[EI_MAG0] = ELFMAG0,
|
||||||
|
[EI_MAG1] = ELFMAG1,
|
||||||
|
[EI_MAG2] = ELFMAG2,
|
||||||
|
[EI_MAG3] = ELFMAG3,
|
||||||
|
[EI_CLASS] = ELFCLASS32,
|
||||||
|
[EI_DATA] = ELFDATA2MSB,
|
||||||
|
[EI_VERSION] = 1,
|
||||||
|
[EI_OSABI] = ELFOSABI_SYSV,
|
||||||
|
[EI_ABIVERSION] = 0,
|
||||||
|
},
|
||||||
|
.e_type = htobe16(ET_REL),
|
||||||
|
.e_machine = htobe16(EM_MIPS),
|
||||||
|
.e_version = htobe32(EV_CURRENT),
|
||||||
|
.e_entry = htobe32(0x00000000),
|
||||||
|
.e_phoff = htobe32(0x00000000),
|
||||||
|
.e_shoff = htobe32(shdrs_offset),
|
||||||
|
.e_flags = htobe32(EF_MIPS_ARCH_3 | EF_MIPS_32BITMODE | EF_MIPS_NOREORDER),
|
||||||
|
.e_ehsize = htobe16(sizeof(Elf32_Ehdr)),
|
||||||
|
.e_phentsize = htobe16(0x0000),
|
||||||
|
.e_phnum = htobe16(0),
|
||||||
|
.e_shentsize = htobe16(sizeof(Elf32_Shdr)),
|
||||||
|
.e_shnum = htobe16(ARRLEN(shdrs)),
|
||||||
|
.e_shstrndx = htobe16(4), /* shstrtab */
|
||||||
|
};
|
||||||
|
fseek(elf, 0, SEEK_SET);
|
||||||
|
fwrite(&ehdr, sizeof(ehdr), 1, elf);
|
||||||
|
|
||||||
|
fflush(elf);
|
||||||
|
fclose(elf);
|
||||||
|
|
||||||
|
// Add it as an additional input file
|
||||||
|
enum ld_plugin_status ps = pl.add_input_file(ofile->path);
|
||||||
|
if (ps != LDPS_OK) {
|
||||||
|
pl.message(LDPL_ERROR, "error adding %s as an additional input file\n", ofile->path);
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LDPS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum ld_plugin_status
|
||||||
|
cleanup(void)
|
||||||
|
{
|
||||||
|
free(pl.string_pool);
|
||||||
|
free(pl.order_path);
|
||||||
|
for (size_t f = 0; f < pl.num_ofiles; f++) {
|
||||||
|
struct bss_ofile *ofile = &pl.ofiles[f];
|
||||||
|
free(ofile->symbol_names);
|
||||||
|
free(ofile->symbols);
|
||||||
|
BITSET_FREE(ofile->symbols_found);
|
||||||
|
}
|
||||||
|
free(pl.ofiles);
|
||||||
|
return LDPS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum ld_plugin_status
|
||||||
|
parse_order_file(const char *order_file)
|
||||||
|
{
|
||||||
|
// Read the entire bss order file and null-terminate it
|
||||||
|
FILE *bss_order = fopen(order_file, "rb");
|
||||||
|
if (bss_order == NULL) {
|
||||||
|
pl.message(LDPL_FATAL, "Could not open bss order file %s for reading: %s", bss_order, strerror(errno));
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek(bss_order, 0, SEEK_END);
|
||||||
|
size_t fsize = ftell(bss_order);
|
||||||
|
fseek(bss_order, 0, SEEK_SET);
|
||||||
|
|
||||||
|
pl.string_pool = malloc((fsize + 1) * sizeof(char));
|
||||||
|
if (fread(pl.string_pool, fsize, 1, bss_order) != 1) {
|
||||||
|
pl.message(LDPL_FATAL, "Failed to read bss order file %s: %s", order_file, strerror(errno));
|
||||||
|
free(pl.string_pool);
|
||||||
|
fclose(bss_order);
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
pl.string_pool[fsize] = '\0';
|
||||||
|
|
||||||
|
fclose(bss_order);
|
||||||
|
|
||||||
|
// Strip comments -> spaces, leaving newlines alone for correct error reporting
|
||||||
|
|
||||||
|
int line = 1;
|
||||||
|
bool comment = false;
|
||||||
|
bool oneline = false;
|
||||||
|
char *s = pl.string_pool;
|
||||||
|
while (*s != '\0') {
|
||||||
|
if (*s == '\n')
|
||||||
|
line++;
|
||||||
|
|
||||||
|
if (*s == '#' || (*s == '/' && s[1] == '/'))
|
||||||
|
comment = true, oneline = true;
|
||||||
|
else if (*s == '/' && s[1] == '*')
|
||||||
|
comment = true, oneline = false;
|
||||||
|
|
||||||
|
if (oneline && *s == '\n')
|
||||||
|
comment = false;
|
||||||
|
|
||||||
|
if (comment && !oneline && *s == '*' && s[1] == '/')
|
||||||
|
comment = false, s[0] = s[1] = ' ';
|
||||||
|
|
||||||
|
if (comment && (*s != '\n'))
|
||||||
|
*s = ' ';
|
||||||
|
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *errmsg = "?";
|
||||||
|
|
||||||
|
#define SYNTAX_ERR(msg) do { errmsg = msg; goto syntaxerror; } while (0)
|
||||||
|
|
||||||
|
if (comment && !oneline)
|
||||||
|
SYNTAX_ERR("Unclosed multi-line comment");
|
||||||
|
|
||||||
|
// Before any detailed parsing, allocate memory based on upper bounds for the number of output files and symbols
|
||||||
|
size_t total_file_count = 0;
|
||||||
|
s = pl.string_pool;
|
||||||
|
for (size_t i = 0; i < fsize; i++, s++) {
|
||||||
|
if (*s == '{')
|
||||||
|
total_file_count++;
|
||||||
|
}
|
||||||
|
pl.num_ofiles = total_file_count;
|
||||||
|
pl.ofiles = malloc(total_file_count * sizeof(struct bss_ofile));
|
||||||
|
|
||||||
|
size_t cur_ofile = (size_t)-1;
|
||||||
|
size_t cur_symbol = 0;
|
||||||
|
|
||||||
|
s = pl.string_pool;
|
||||||
|
for (size_t i = 0; i < fsize; i++, s++) {
|
||||||
|
if (*s == '{') {
|
||||||
|
if (cur_ofile != (size_t)-1) {
|
||||||
|
assert (cur_ofile < total_file_count);
|
||||||
|
pl.ofiles[cur_ofile].num_symbols = cur_symbol;
|
||||||
|
pl.ofiles[cur_ofile].symbols = malloc(cur_symbol * sizeof(Elf32_Sym));
|
||||||
|
pl.ofiles[cur_ofile].symbol_names = malloc(cur_symbol * sizeof(char *));
|
||||||
|
pl.ofiles[cur_ofile].symbols_found = BITSET_ALLOC(cur_symbol);
|
||||||
|
cur_symbol = 0;
|
||||||
|
}
|
||||||
|
cur_ofile++;
|
||||||
|
} else if (*s == ';') {
|
||||||
|
cur_symbol++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert (cur_ofile < total_file_count);
|
||||||
|
pl.ofiles[cur_ofile].num_symbols = cur_symbol;
|
||||||
|
pl.ofiles[cur_ofile].symbols = malloc(cur_symbol * sizeof(Elf32_Sym));
|
||||||
|
pl.ofiles[cur_ofile].symbol_names = malloc(cur_symbol * sizeof(char *));
|
||||||
|
pl.ofiles[cur_ofile].symbols_found = BITSET_ALLOC(cur_symbol);
|
||||||
|
|
||||||
|
bool quote = false;
|
||||||
|
bool eof_ok = false;
|
||||||
|
char *start = NULL;
|
||||||
|
char *end = NULL;
|
||||||
|
void *next = &&fpath;
|
||||||
|
line = 1;
|
||||||
|
cur_ofile = (size_t)-1;
|
||||||
|
cur_symbol = 0;
|
||||||
|
|
||||||
|
s = pl.string_pool;
|
||||||
|
whitespace:
|
||||||
|
// Skip whitespace, count newlines for syntax error messages
|
||||||
|
while (iswhitespace(*s)) {
|
||||||
|
if (*s == '\n') line++;
|
||||||
|
s++;
|
||||||
|
};
|
||||||
|
// If we're at EOF, check if that's OK or whether it's a syntax error
|
||||||
|
if (*s == '\0') {
|
||||||
|
if (eof_ok) goto eof;
|
||||||
|
SYNTAX_ERR("Unexpected EOF");
|
||||||
|
}
|
||||||
|
goto *next;
|
||||||
|
|
||||||
|
fpath:
|
||||||
|
// We're looking for a file path now, up until an opening brace {.
|
||||||
|
// If the file path is unquoted, the first whitespace encountered cuts this short, but if the file path
|
||||||
|
// is quoted whitespace will be included in the path up until the closing quote. If quoted, newlines will
|
||||||
|
// cause a syntax error if used between the quotes.
|
||||||
|
eof_ok = false;
|
||||||
|
// Check quote immediately, it's only allowed at the start
|
||||||
|
if (*s == '"') s++, quote = true;
|
||||||
|
|
||||||
|
// Consume the path
|
||||||
|
start = s;
|
||||||
|
while (*s != '{') {
|
||||||
|
if (*s == '\0') SYNTAX_ERR("Unexpected EOF");
|
||||||
|
if (!quote && iswhitespace(*s)) break; // Unquoted whitespace cuts this short
|
||||||
|
if (quote && *s == '\n') SYNTAX_ERR("Quoted string spanning multiple lines");
|
||||||
|
if (quote && *s == '"') break; // Ending quotes cuts this short
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
end = s;
|
||||||
|
|
||||||
|
// Check for closing quote
|
||||||
|
if (*s == '"') {
|
||||||
|
if (!quote) SYNTAX_ERR("Found a closing quote with no opening quote");
|
||||||
|
quote = false;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consume any whitespace up to {
|
||||||
|
next = &&obrace;
|
||||||
|
goto whitespace;
|
||||||
|
|
||||||
|
obrace:
|
||||||
|
// We're looking for an opening brace character {, anything else is a fail
|
||||||
|
if (*s++ != '{') SYNTAX_ERR("Expected an {");
|
||||||
|
// NULL-terminate the file path in-place and save it
|
||||||
|
*end = '\0';
|
||||||
|
cur_ofile++;
|
||||||
|
cur_symbol = 0;
|
||||||
|
assert(cur_ofile < total_file_count);
|
||||||
|
pl.ofiles[cur_ofile].path = start;
|
||||||
|
// Consume whitespace up to the first symbol name
|
||||||
|
next = &&sym;
|
||||||
|
goto whitespace;
|
||||||
|
|
||||||
|
sym:
|
||||||
|
// Symbol names are similar to the file path, but we're looking to end on a semicolon ;
|
||||||
|
// If the symbol name is unquoted, the first whitespace encountered cuts this short, but if the symbol name
|
||||||
|
// is quoted whitespace will be included in the name up until the closing quote. If quoted, newlines will
|
||||||
|
// cause a syntax error if used between the quotes.
|
||||||
|
// Check quote immediately, it's only allowed at the start
|
||||||
|
if (*s == '"') quote = true, s++;
|
||||||
|
|
||||||
|
// Consume the symbol name
|
||||||
|
start = s;
|
||||||
|
while (*s != ';') {
|
||||||
|
if (*s == '\0') SYNTAX_ERR("Unexpected EOF");
|
||||||
|
if (quote && *s == '\n') SYNTAX_ERR("Quoted string spanning multiple lines");
|
||||||
|
// Unlike file paths, we're not friendly to whitespace between the end of the symbol and the semicolon
|
||||||
|
// TODO we could be though?
|
||||||
|
if (!quote && iswhitespace(*s)) SYNTAX_ERR("Whitespace in unquoted symbol name");
|
||||||
|
if (quote && *s == '"') {
|
||||||
|
// It's tempting to allow whitespace here but it would be inconsistent with the above, but if the above
|
||||||
|
// changes this should similarly allow whitespace
|
||||||
|
if (s[1] != ';') SYNTAX_ERR("Expected ;");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
end = s;
|
||||||
|
|
||||||
|
// Check for end quote
|
||||||
|
if (*s == '"') {
|
||||||
|
if (!quote) SYNTAX_ERR("Found a closing quote with no opening quote");
|
||||||
|
quote = false;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
// This assertion should always be true unless the above logic is wrong, it's
|
||||||
|
// not meant to be caused by a syntax error.
|
||||||
|
assert(*s++ == ';');
|
||||||
|
|
||||||
|
// NULL-terminate
|
||||||
|
*end = '\0';
|
||||||
|
assert(cur_symbol < pl.ofiles[cur_ofile].num_symbols);
|
||||||
|
pl.ofiles[cur_ofile].symbol_names[cur_symbol++] = start;
|
||||||
|
|
||||||
|
// Consume any whitespace following the semicolon
|
||||||
|
next = &&cbrace;
|
||||||
|
goto whitespace;
|
||||||
|
|
||||||
|
cbrace:
|
||||||
|
// If the first non-whitespace character after a semicolon isn't }, assume it's another
|
||||||
|
// symbol in the list. If it is }, this is the end of the list.
|
||||||
|
if (*s != '}') goto sym;
|
||||||
|
s++;
|
||||||
|
// This might be a valid end of file (after any trailing whitespace) if this is the last
|
||||||
|
// output file in the specification.
|
||||||
|
pl.ofiles[cur_ofile].num_symbols = cur_symbol;
|
||||||
|
eof_ok = true;
|
||||||
|
next = &&fpath;
|
||||||
|
goto whitespace;
|
||||||
|
|
||||||
|
eof:
|
||||||
|
// Reached end of file, we must have all output files and their symbols at this point.
|
||||||
|
assert(cur_ofile < pl.num_ofiles);
|
||||||
|
// Reduce the number of files to the actual number from the upper bound
|
||||||
|
pl.num_ofiles = cur_ofile + 1;
|
||||||
|
return LDPS_OK;
|
||||||
|
|
||||||
|
syntaxerror:
|
||||||
|
pl.message(LDPL_FATAL, "%s(%d): Syntax error: %s", pl.order_path, line, errmsg);
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum ld_plugin_status
|
||||||
|
parse_option(const char *opt)
|
||||||
|
{
|
||||||
|
if (strequ(opt, "order=")) {
|
||||||
|
pl.order_path = strdup(opt + sizeof("order=") - 1);
|
||||||
|
return LDPS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Unknown option: %s\n", opt);
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ld_plugin_status
|
||||||
|
onload(struct ld_plugin_tv *tv)
|
||||||
|
{
|
||||||
|
enum ld_plugin_status ps;
|
||||||
|
|
||||||
|
// Initialize our state
|
||||||
|
memset(&pl, 0, sizeof(pl));
|
||||||
|
pl.api_version = -1;
|
||||||
|
pl.gnu_ld_version = -1;
|
||||||
|
pl.linker_output = -1;
|
||||||
|
|
||||||
|
// Parse the transfer vector
|
||||||
|
for (struct ld_plugin_tv *ptv = tv; ptv->tv_tag != LDPT_NULL; ptv++) {
|
||||||
|
switch (ptv->tv_tag) {
|
||||||
|
case LDPT_OPTION:
|
||||||
|
if (ps = parse_option(ptv->tv_u.tv_string), ps != LDPS_OK)
|
||||||
|
return ps;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_MESSAGE:
|
||||||
|
pl.message = ptv->tv_u.tv_message;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_API_VERSION:
|
||||||
|
pl.api_version = ptv->tv_u.tv_val;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_GNU_LD_VERSION:
|
||||||
|
pl.gnu_ld_version = ptv->tv_u.tv_val;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_LINKER_OUTPUT:
|
||||||
|
pl.linker_output = ptv->tv_u.tv_val;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_OUTPUT_NAME:
|
||||||
|
pl.output_name = ptv->tv_u.tv_string;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_REGISTER_CLAIM_FILE_HOOK:
|
||||||
|
pl.register_claim_file = ptv->tv_u.tv_register_claim_file;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
|
||||||
|
pl.register_all_symbols_read = ptv->tv_u.tv_register_all_symbols_read;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_REGISTER_CLEANUP_HOOK:
|
||||||
|
pl.register_cleanup = ptv->tv_u.tv_register_cleanup;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_ADD_SYMBOLS:
|
||||||
|
pl.add_symbols = ptv->tv_u.tv_add_symbols;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_GET_INPUT_FILE:
|
||||||
|
pl.get_input_file = ptv->tv_u.tv_get_input_file;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_GET_SYMBOLS:
|
||||||
|
pl.get_symbols = ptv->tv_u.tv_get_symbols;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_GET_SYMBOLS_V2:
|
||||||
|
pl.get_symbols_v2 = ptv->tv_u.tv_get_symbols;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDPT_ADD_INPUT_FILE:
|
||||||
|
pl.add_input_file = ptv->tv_u.tv_add_input_file;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check pl.message
|
||||||
|
if (pl.message == NULL) {
|
||||||
|
fprintf(stderr, "No message() provided to plugin");
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check args
|
||||||
|
|
||||||
|
if (pl.order_path == NULL) {
|
||||||
|
pl.message(LDPL_ERROR, "Missing option -plugin-opt order=<order.txt>");
|
||||||
|
return LDPS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the order file
|
||||||
|
|
||||||
|
if (ps = parse_order_file(pl.order_path), ps != LDPS_OK)
|
||||||
|
return ps;
|
||||||
|
|
||||||
|
// Register callbacks
|
||||||
|
|
||||||
|
pl.register_claim_file(claim_file);
|
||||||
|
pl.register_all_symbols_read(all_symbols_read);
|
||||||
|
pl.register_cleanup(cleanup);
|
||||||
|
|
||||||
|
return LDPS_OK;
|
||||||
|
}
|
13
tools/patch_ique_kaleido_reloc.py
Normal file
13
tools/patch_ique_kaleido_reloc.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Patches kaleido bss size in relocations for matching builds.
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
with open(sys.argv[1], "r+") as reloc_sfile:
|
||||||
|
contents = reloc_sfile.read()
|
||||||
|
contents = contents.replace(".word _ovl_kaleido_scopeSegmentBssSize\n", ".word 0x10\n")
|
||||||
|
reloc_sfile.seek(0)
|
||||||
|
reloc_sfile.write(contents)
|
||||||
|
reloc_sfile.truncate()
|
Loading…
Add table
Reference in a new issue