From d0bd1df531b6b118222ace6679d1fa8a749a7d02 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 21 Jun 2019 09:54:48 -0400 Subject: [PATCH 01/19] Merge two fields in party_menu heap struct --- src/party_menu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/party_menu.c b/src/party_menu.c index 9a021aa41..66069804b 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -107,8 +107,7 @@ struct Struct203CEC4 u8 windowId[3]; u8 actions[8]; u8 listSize; - u16 palBuffer[0xB0]; - u8 filler[0xA0]; + u16 palBuffer[0x100]; s16 data[16]; }; From 3f43523352b279fc4498ee4bfde2213504e3ece8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 21 Jun 2019 12:38:11 -0400 Subject: [PATCH 02/19] Add comment to merged field --- src/party_menu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/party_menu.c b/src/party_menu.c index 66069804b..f20bdff51 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -107,7 +107,11 @@ struct Struct203CEC4 u8 windowId[3]; u8 actions[8]; u8 listSize; - u16 palBuffer[0x100]; + // In vanilla Emerald, only the first 0xB0 hwords (0x160 bytes) are actually used. + // However, a full 0x100 hwords (0x200 bytes) are allocated. + // It is likely that the 0x160 value used below is a constant defined by + // bin2c, the utility used to encode the compressed palette data. + u16 palBuffer[BG_PLTT_SIZE / sizeof(u16)]; s16 data[16]; }; From fb06e4a3c94ae17b73df6d3aecf2d18213aa183e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 26 Jun 2019 08:13:38 -0400 Subject: [PATCH 03/19] Modernize code Can compile with arm-none-eabi-gcc 8.3.0 gbafix correctly handles ELF input --- Makefile | 28 +- include/gba/defines.h | 11 + include/gba/macro.h | 25 + include/global.h | 4 + include/graphics.h | 3 - include/player_pc.h | 2 + include/strings.h | 1 - ld_script.txt | 20 + src/battle_anim_effects_1.c | 2 +- src/battle_dome.c | 4 +- src/bg.c | 13 +- src/contest.c | 4 +- src/contest_painting.c | 10 +- src/dma3_manager.c | 2 +- src/dodrio_berry_picking.c | 2 +- src/ereader_helpers.c | 22 +- src/fire.c | 1 + src/ghost.c | 3 +- src/link.c | 31 +- src/link_rfu.c | 11 +- src/m4a.c | 1 + src/main.c | 2 +- src/mauville_old_man.c | 2 +- src/multiboot.c | 2 +- src/pokemon_size_record.c | 2 +- src/reset_rtc_screen.c | 2 +- src/roulette.c | 10 +- src/roulette_util.c | 1 + src/save.c | 5 +- src/scrcmd.c | 2 +- src/script_menu.c | 4 +- src/tv.c | 9 +- src/union_room.c | 6 +- src/union_room_battle.c | 2 +- tools/gbafix/elf.h | 3147 +++++++++++++++++++++++++++++++++++ tools/gbafix/gbafix.c | 464 +++--- 36 files changed, 3552 insertions(+), 308 deletions(-) create mode 100644 tools/gbafix/elf.h diff --git a/Makefile b/Makefile index bf8c498ae..cffbcf87f 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,10 @@ TITLE := POKEMON EMER GAME_CODE := BPEE MAKER_CODE := 01 REVISION := 0 +MODERN ?= 0 SHELL := /bin/bash -o pipefail -ROM := pokeemerald.gba -OBJ_DIR := build/emerald - ELF = $(ROM:.gba=.elf) MAP = $(ROM:.gba=.map) @@ -34,12 +32,21 @@ DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR) SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR) MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR) -ASFLAGS := -mcpu=arm7tdmi +ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) +ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm +ROM := pokeemerald.gba +OBJ_DIR := build/emerald +else +CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) +override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations +ROM := pokeemerald_modern.gba +OBJ_DIR := build/modern +endif -CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -Wno-trigraphs +CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -Wno-trigraphs -DMODERN=$(MODERN) LDFLAGS = -Map ../../$(MAP) @@ -109,7 +116,10 @@ clean: tidy tidy: rm -f $(ROM) $(ELF) $(MAP) +ifeq ($(MODERN),0) + @$(MAKE) tidy MODERN=1 rm -r build/* +endif include graphics_file_rules.mk include map_data_rules.mk @@ -133,6 +143,7 @@ sound/direct_sound_samples/cry_%.bin: sound/direct_sound_samples/cry_%.aif ; $(A sound/%.bin: sound/%.aif ; $(AIF) $< $@ +ifeq ($(MODERN),0) $(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/libc.o: CFLAGS := -O2 @@ -145,6 +156,7 @@ $(C_BUILDDIR)/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork $(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding +endif ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: c_dep := @@ -197,7 +209,9 @@ $(OBJ_DIR)/ld_script.ld: ld_script.txt $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_comm $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + $(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent $(ROM): $(ELF) - $(OBJCOPY) -O binary $< $@ - $(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent + $(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@ + +modern: ; @$(MAKE) MODERN=1 diff --git a/include/gba/defines.h b/include/gba/defines.h index b68a2ad1e..b95946b15 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -6,9 +6,20 @@ #define TRUE 1 #define FALSE 0 +#define BSS_DATA __attribute__((section(".bss"))) +#if MODERN +#define IWRAM_DATA +#else #define IWRAM_DATA __attribute__((section("iwram_data"))) +#endif #define EWRAM_DATA __attribute__((section("ewram_data"))) +#if MODERN +#define NOINLINE __attribute__((noinline)) +#else +#define NOINLINE +#endif + #define ALIGNED(n) __attribute__((aligned(n))) #define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0) diff --git a/include/gba/macro.h b/include/gba/macro.h index 3b35a1946..197febede 100644 --- a/include/gba/macro.h +++ b/include/gba/macro.h @@ -192,4 +192,29 @@ REG_IME = imeTemp; \ } \ +#if MODERN +#define FLOAT_UNS(x, bit) ({ \ + s##bit sx = x; \ + float fx = (float)sx; \ + if (sx < 0) fx += (1 << (bit - 1)) * 2.0f; \ + fx; \ +}) +#define DOUBLE_UNS(x, bit) ({ \ + s##bit sx = x; \ + double dx = (double)sx; \ + if (sx < 0) dx += (1 << (bit - 1)) * 2.0; \ + dx; \ +}) +#else +#define FLOAT_UNS(x, bit) ((float)(x)) +#define DOUBLE_UNS(x, bit) ((double)(x)) +#endif //MODERN + +#define FLOAT_U8(x) FLOAT_UNS(x, 8) +#define FLOAT_U16(x) FLOAT_UNS(x, 16) +#define FLOAT_U32(x) FLOAT_UNS(x, 32) +#define DOUBLE_U8(x) DOUBLE_UNS(x, 8) +#define DOUBLE_U16(x) DOUBLE_UNS(x, 16) +#define DOUBLE_U32(x) DOUBLE_UNS(x, 32) + #endif // GUARD_GBA_MACRO_H diff --git a/include/global.h b/include/global.h index 969680dd7..712a40866 100644 --- a/include/global.h +++ b/include/global.h @@ -62,6 +62,10 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) +#if MODERN +#define abs(x) (((x) < 0) ? -(x) : (x)) +#endif + // Extracts the upper 16 bits of a 32-bit number #define HIHALF(n) (((n) & 0xFFFF0000) >> 16) diff --git a/include/graphics.h b/include/graphics.h index 43b014a9f..50bb5774e 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4005,9 +4005,6 @@ extern const u32 gBerryPalette_Starf[]; extern const u32 gBerryPic_Enigma[]; extern const u32 gBerryPalette_Enigma[]; -//credits -extern const u32 gCreditsCopyrightEnd_Gfx[]; - //pokenav extern const u8 gPokenavConditionMarker_Gfx[]; extern const u16 gPokenavConditionMarker_Pal[]; diff --git a/include/player_pc.h b/include/player_pc.h index 53bb25c6b..219c11440 100644 --- a/include/player_pc.h +++ b/include/player_pc.h @@ -1,6 +1,8 @@ #ifndef GUARD_PLAYER_PC_H #define GUARD_PLAYER_PC_H +#include "menu.h" + // local task defines #define PAGE_INDEX data[0] #define ITEMS_ABOVE_TOP data[1] diff --git a/include/strings.h b/include/strings.h index f30e82321..36a92281e 100644 --- a/include/strings.h +++ b/include/strings.h @@ -485,7 +485,6 @@ extern const u8 gText_CryOf[]; extern const u8 gText_SizeComparedTo[]; extern const u8 gText_PokedexRegistration[]; extern const u8 gText_UnkCtrlF908Clear01[]; -extern const u8 sText_TenDashes2[]; extern const u8 gText_5MarksPokemon[]; extern const u8 gText_UnkHeight[]; extern const u8 gText_UnkWeight[]; diff --git a/ld_script.txt b/ld_script.txt index b1c81f6e4..b35b108ea 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -423,7 +423,9 @@ SECTIONS { data/io_reg.o(.rodata); src/string_util.o(.rodata); src/link.o(.rodata); + src/link.o(.rodata.str1.4); src/link_rfu.o(.rodata); + src/link_rfu.o(.rodata.str1.4); src/union_room.o(.rodata); src/mystery_gift.o(.rodata); src/union_room_player_avatar.o(.rodata); @@ -434,6 +436,7 @@ SECTIONS { src/mevent_client.o(.rodata); src/mevent_scripts.o(.rodata); src/union_room_chat.o(.rodata); + src/berry_crush.o(.rodata); data/berry_crush.o(.rodata); data/berry_powder.o(.rodata); src/dodrio_berry_picking.o(.rodata); @@ -442,6 +445,7 @@ SECTIONS { data/pokemon_jump.o(.rodata); src/rtc.o(.rodata); src/main_menu.o(.rodata); + src/battle_controllers.o(.rodata); src/rom_8034C54.o(.rodata); src/data.o(.rodata); src/battle_bg.o(.rodata); @@ -451,6 +455,7 @@ SECTIONS { src/battle_controller_player.o(.rodata); data/smokescreen.o(.rodata); src/battle_controller_opponent.o(.rodata); + src/battle_ai_switch_items.o(.rodata); src/battle_controller_link_opponent.o(.rodata); src/pokemon.o(.rodata); src/trig.o(.rodata); @@ -473,6 +478,7 @@ SECTIONS { src/event_object_movement.o(.rodata); src/text_window.o(.rodata); src/scrcmd.o(.rodata); + src/field_control_avatar.o(.rodata); src/coord_event_weather.o(.rodata); src/field_tasks.o(.rodata); src/reset_rtc_screen.o(.rodata); @@ -483,6 +489,7 @@ SECTIONS { src/battle_anim.o(.rodata); src/battle_anim_mons.o(.rodata); data/map_events.o(.rodata); + src/reshow_battle_screen.o(.rodata); src/battle_anim_status_effects.o(.rodata); src/title_screen.o(.rodata); src/field_weather.o(.rodata); @@ -493,6 +500,7 @@ SECTIONS { src/trainer_see.o(.rodata); src/wild_encounter.o(.rodata); src/field_effect.o(.rodata); + src/scanline_effect.o(.rodata); src/option_menu.o(.rodata); src/pokedex.o(.rodata); src/trainer_card.o(.rodata); @@ -515,12 +523,14 @@ SECTIONS { src/record_mixing.o(.rodata); src/secret_base.o(.rodata); src/tv.o(.rodata); + src/contest_link_80F57C4.o(.rodata); data/contest_link_80F57C4.o(.rodata); src/script_pokemon_util_80F87D8.o(.rodata); src/pokemon_size_record.o(.rodata) src/fldeff_misc.o(.rodata); src/field_special_scene.o(.rodata); src/rotating_gate.o(.rodata); + src/contest_link_80FC4F4.o(.rodata); src/item_use.o(.rodata); src/battle_anim_effects_1.o(.rodata); src/battle_anim_effects_2.o(.rodata); @@ -549,6 +559,7 @@ SECTIONS { src/menu_helpers.o(.rodata); src/heal_location.o(.rodata); src/region_map.o(.rodata); + src/contest_painting_effects.o(.rodata); data/contest_painting_effects.o(.rodata); src/decoration.o(.rodata); src/slot_machine.o(.rodata); @@ -575,6 +586,7 @@ SECTIONS { src/save.o(.rodata); src/field_effect_helpers.o(.rodata); src/contest_ai.o(.rodata); + src/battle_anim_sound_tasks.o(.rodata); src/battle_controller_safari.o(.rodata); src/battle_anim_effects_3.o(.rodata); src/move_relearner.o(.rodata); @@ -617,6 +629,7 @@ SECTIONS { src/battle_arena.o(.rodata); src/battle_factory.o(.rodata); src/battle_pike.o(.rodata); + src/mossdeep_gym.o(.rodata); data/mossdeep_gym.o(.rodata); src/battle_pyramid.o(.rodata); src/item_menu.o(.rodata); @@ -626,6 +639,7 @@ SECTIONS { src/party_menu.o(.rodata); src/battle_tent.o(.rodata); src/unk_text_util_2.o(.rodata); + src/multiboot.o(.rodata); src/unk_81BAD84.o(.rodata); src/battle_controller_player_partner.o(.rodata); src/mirage_tower.o(.rodata); @@ -638,11 +652,16 @@ SECTIONS { src/pokenav_match_call_ui.o(.rodata); src/pokenav_unk_1.o(.rodata); data/pokenav.o(.rodata); + src/pokenav_unk_3.o(.rodata); + src/pokenav_unk_4.o(.rodata); + src/pokenav_unk_5.o(.rodata); src/pokenav_unk_10.o(.rodata); src/pokenav_match_call_data.o(.rodata); src/menu_specialized.o(.rodata); + src/ereader_helpers.o(.rodata); data/ereader_helpers.o(.rodata); src/faraway_island.o(.rodata); + src/ereader_screen.o(.rodata); data/ereader_screen.o(.rodata); src/trainer_hill.o(.rodata); src/rayquaza_scene.o(.rodata); @@ -1195,6 +1214,7 @@ SECTIONS { lib_rodata : SUBALIGN(4) { + src/m4a.o(.rodata); src/agb_flash.o(.rodata); src/agb_flash_1m.o(.rodata); src/agb_flash_mx.o(.rodata); diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 49bb0216b..15b73a1e0 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -5354,7 +5354,7 @@ void sub_8102EB0(struct Sprite* sprite) if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT) { a = gBattleAnimArgs[1]; - (u16)gBattleAnimArgs[1] = -a; + *(u16 *)&gBattleAnimArgs[1] = -a; } sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) + gBattleAnimArgs[1]; diff --git a/src/battle_dome.c b/src/battle_dome.c index 162d46d61..1c116467d 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -1024,13 +1024,13 @@ static const union AnimCmd gUnknown_0860D020[] = static const union AnimCmd gUnknown_0860D028[] = { - ANIMCMD_FRAME(18, 129, .vFlip = TRUE), + ANIMCMD_FRAME(18, 1, .vFlip = TRUE), ANIMCMD_END, }; static const union AnimCmd gUnknown_0860D030[] = { - ANIMCMD_FRAME(16, 65, .hFlip = TRUE), + ANIMCMD_FRAME(16, 1, .hFlip = TRUE), ANIMCMD_END, }; diff --git a/src/bg.c b/src/bg.c index 1826f9a28..abeb49306 100644 --- a/src/bg.c +++ b/src/bg.c @@ -914,7 +914,6 @@ void CopyBgTilemapBufferToVram(u8 bg) void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height) { - const void *srcCopy; u16 destX16; u16 destY16; u16 mode; @@ -924,27 +923,31 @@ void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 wi switch (GetBgType(bg)) { case 0: - srcCopy = src; + { + const u16 * srcCopy = src; for (destY16 = destY; destY16 < (destY + height); destY16++) { for (destX16 = destX; destX16 < (destX + width); destX16++) { - ((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *((u16*)srcCopy)++; + ((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *srcCopy++; } } break; + } case 1: - srcCopy = src; + { + const u8 * srcCopy = src; mode = GetBgMetricAffineMode(bg, 0x1); for (destY16 = destY; destY16 < (destY + height); destY16++) { for (destX16 = destX; destX16 < (destX + width); destX16++) { - ((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *((u8*)srcCopy)++; + ((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *srcCopy++; } } break; } + } } } diff --git a/src/contest.c b/src/contest.c index eb3252f72..869300a92 100644 --- a/src/contest.c +++ b/src/contest.c @@ -269,8 +269,6 @@ extern const u8 gText_Contest_Fear[]; extern const u8 gText_BDot[]; extern const u8 gText_CDot[]; extern const u8 *const gUnknown_08587E10[]; -extern const struct SpriteTemplate gSpriteTemplate_8587AD0; -extern const struct SpriteTemplate gSpriteTemplate_8587B18[]; extern void (*const gContestEffectFuncs[])(void); static const u8 gUnknown_08587A6C[] = @@ -1268,7 +1266,7 @@ static void sub_80D8108(u8 taskId) gTasks[taskId].data[0]++; break; case 1: - (s16)gBattle_BG1_Y += 7; + *(s16*)&gBattle_BG1_Y += 7; if ((s16)gBattle_BG1_Y <= 160) break; gTasks[taskId].data[0]++; diff --git a/src/contest_painting.c b/src/contest_painting.c index b43923c7b..4e8fd72f7 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -28,11 +28,11 @@ struct ContestWinner *gUnknown_030061C0; u16 *gContestPaintingMonPalette; // IWRAM bss -IWRAM_DATA u8 gContestPaintingState; -IWRAM_DATA u16 gContestPaintingMosaicVal; -IWRAM_DATA u16 gContestPaintingFadeCounter; -IWRAM_DATA bool8 gUnknown_030011F6; -IWRAM_DATA u8 gContestPaintingWindowId; +static u8 gContestPaintingState; +static u16 gContestPaintingMosaicVal; +static u16 gContestPaintingFadeCounter; +static bool8 gUnknown_030011F6; +static u8 gContestPaintingWindowId; static void ShowContestPainting(void); static void HoldContestPainting(void); diff --git a/src/dma3_manager.c b/src/dma3_manager.c index 51fa7072d..f11bf33dd 100644 --- a/src/dma3_manager.c +++ b/src/dma3_manager.c @@ -8,7 +8,7 @@ #define DMA_REQUEST_COPY16 3 #define DMA_REQUEST_FILL16 4 -IWRAM_DATA struct +BSS_DATA struct { const u8 *src; u8 *dest; diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 966dccfcf..e9ff76f49 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -145,7 +145,7 @@ EWRAM_DATA u16 * gUnknown_02022CE4[4] = {NULL}; EWRAM_DATA struct DodrioBerryPickingStruct_2022CF4 * gUnknown_02022CF4 = NULL; EWRAM_DATA struct DodrioBerryPickingSubstruct_0160 * gUnknown_02022CF8 = NULL; -IWRAM_DATA bool32 gUnknown_03000DB0; +static bool32 gUnknown_03000DB0; void sub_8024A1C(void); void sub_8024A30(struct DodrioBerryPickingStruct *); diff --git a/src/ereader_helpers.c b/src/ereader_helpers.c index cd64afe0e..11aaaafe7 100755 --- a/src/ereader_helpers.c +++ b/src/ereader_helpers.c @@ -26,17 +26,17 @@ static void sub_81D414C(void); static void sub_81D3F1C(u32, u32*, u32*); static void sub_81D3F68(void); -IWRAM_DATA struct Unknown030012C8 gUnknown_030012C8; -IWRAM_DATA u16 gUnknown_030012E0; -IWRAM_DATA u16 gUnknown_030012E2; -IWRAM_DATA u16 gUnknown_030012E4; -IWRAM_DATA u16 gUnknown_030012E6; -IWRAM_DATA u32 gUnknown_030012E8; -IWRAM_DATA u16 gUnknown_030012EC; -IWRAM_DATA u16 gUnknown_030012EE; -IWRAM_DATA u16 gUnknown_030012F0; -IWRAM_DATA u16 gUnknown_030012F2; -IWRAM_DATA u16 gUnknown_030012F4; +static struct Unknown030012C8 gUnknown_030012C8; +static u16 gUnknown_030012E0; +static u16 gUnknown_030012E2; +static u16 gUnknown_030012E4; +static u16 gUnknown_030012E6; +static u32 gUnknown_030012E8; +static u16 gUnknown_030012EC; +static u16 gUnknown_030012EE; +static u16 gUnknown_030012F0; +static u16 gUnknown_030012F2; +static u16 gUnknown_030012F4; extern const u8 gUnknown_08625B6C[][0x148]; diff --git a/src/fire.c b/src/fire.c index d428dc13b..2998d46ca 100644 --- a/src/fire.c +++ b/src/fire.c @@ -891,6 +891,7 @@ static void sub_81094D0(u8 taskId) // animate Move_ERUPTION? break; default: + break; } } diff --git a/src/ghost.c b/src/ghost.c index 97b86aa76..dd29fb7ca 100644 --- a/src/ghost.c +++ b/src/ghost.c @@ -1148,7 +1148,8 @@ static void sub_8112B78(struct Sprite *sprite) if (++coeffB > 16) coeffB = 16; - if (--(s16)coeffA < 0) + --coeffA; + if ((s16)coeffA < 0) coeffA = 0; SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(coeffA, coeffB)); diff --git a/src/link.c b/src/link.c index bcdcb52a4..9928b48da 100644 --- a/src/link.c +++ b/src/link.c @@ -52,22 +52,21 @@ struct LinkTestBGInfo // Static RAM declarations -IWRAM_DATA struct BlockTransfer sBlockSend; -IWRAM_DATA u32 link_c_unused_03000d1c; -IWRAM_DATA struct BlockTransfer sBlockRecv[MAX_LINK_PLAYERS]; -IWRAM_DATA u32 sBlockSendDelayCounter; -IWRAM_DATA u32 gUnknown_03000D54; -IWRAM_DATA u8 gUnknown_03000D58; -IWRAM_DATA u32 sPlayerDataExchangeStatus; -IWRAM_DATA u32 gUnknown_03000D60; -IWRAM_DATA u8 sLinkTestLastBlockSendPos; -ALIGNED() IWRAM_DATA u8 sLinkTestLastBlockRecvPos[MAX_LINK_PLAYERS]; -IWRAM_DATA u8 sNumVBlanksWithoutSerialIntr; -IWRAM_DATA bool8 sSendBufferEmpty; -IWRAM_DATA u16 sSendNonzeroCheck; -IWRAM_DATA u16 sRecvNonzeroCheck; -IWRAM_DATA u8 sChecksumAvailable; -IWRAM_DATA u8 sHandshakePlayerCount; +static struct BlockTransfer sBlockSend; +static struct BlockTransfer sBlockRecv[MAX_LINK_PLAYERS]; +static u32 sBlockSendDelayCounter; +static u32 gUnknown_03000D54; +static u8 gUnknown_03000D58; +static u32 sPlayerDataExchangeStatus; +static u32 gUnknown_03000D60; +static u8 sLinkTestLastBlockSendPos; +static u8 sLinkTestLastBlockRecvPos[MAX_LINK_PLAYERS]; +static u8 sNumVBlanksWithoutSerialIntr; +static bool8 sSendBufferEmpty; +static u16 sSendNonzeroCheck; +static u16 sRecvNonzeroCheck; +static u8 sChecksumAvailable; +static u8 sHandshakePlayerCount; u16 gLinkPartnersHeldKeys[6]; u32 gLinkDebugSeed; diff --git a/src/link_rfu.c b/src/link_rfu.c index 9732e9889..ae36493a2 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -24,10 +24,10 @@ extern u16 gHeldKeyCodeToSend; struct UnkRfuStruct_1 gUnknown_03004140; struct UnkRfuStruct_2 gUnknown_03005000; -IWRAM_DATA u8 gUnknown_03000D74; -ALIGNED(4) IWRAM_DATA u8 gUnknown_03000D78[8]; -IWRAM_DATA u8 gUnknown_03000D80[16]; -IWRAM_DATA u16 gUnknown_03000D90[8]; +BSS_DATA u8 gUnknown_03000D74; +ALIGNED(4) BSS_DATA u8 gUnknown_03000D78[8]; +BSS_DATA u8 gUnknown_03000D80[16]; +BSS_DATA u16 gUnknown_03000D90[8]; EWRAM_DATA u8 gWirelessStatusIndicatorSpriteId = 0; EWRAM_DATA ALIGNED(4) struct UnkLinkRfuStruct_02022B14 gUnknown_02022B14 = {}; @@ -2021,6 +2021,8 @@ void sub_800DBF8(u8 *q1, u8 mode) } } +// File boundary here maybe? + void PkmnStrToASCII(u8 *q1, const u8 *q2) { s32 i; @@ -5191,4 +5193,3 @@ u32 GetRfuRecvQueueLength(void) { return gUnknown_03005000.unk_124.unk_8c2; } - diff --git a/src/m4a.c b/src/m4a.c index 7b4441ca4..267a72657 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -1,3 +1,4 @@ +#include #include "gba/m4a_internal.h" extern const u8 gCgb3Vol[]; diff --git a/src/main.c b/src/main.c index 40381bb68..d0c9ff7b4 100644 --- a/src/main.c +++ b/src/main.c @@ -85,7 +85,7 @@ void EnableVCountIntrAtLine150(void); void AgbMain() { - RegisterRamReset(RESET_ALL); + RegisterRamReset(MODERN ? RESET_ALL & ~RESET_IWRAM : RESET_ALL); *(vu16 *)BG_PLTT = 0x7FFF; InitGpuRegManager(); REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 8bb9cb6e4..64f04f3bc 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -33,7 +33,7 @@ static void Task_BardSong(u8 taskId); static void StorytellerSetup(void); static void Storyteller_ResetFlag(void); -IWRAM_DATA u8 sSelectedStory; +static u8 sSelectedStory; struct BardSong gBardSong; diff --git a/src/multiboot.c b/src/multiboot.c index da90a55c0..5cc3ad17e 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -435,7 +435,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp) #undef must_data } -static void MultiBootWaitCycles(u32 cycles) +static NOINLINE void MultiBootWaitCycles(u32 cycles) { asm("mov r2, pc"); asm("lsr r2, #24"); diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index f63e1ccba..d70f57f47 100644 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -97,7 +97,7 @@ static void FormatMonSizeRecord(u8 *string, u32 size) { #ifdef UNITS_IMPERIAL //Convert size from centimeters to inches - size = (double)(size * 10) / (CM_PER_INCH * 10); + size = DOUBLE_U32(size * 10) / (CM_PER_INCH * 10); #endif string = ConvertIntToDecimalStringN(string, size / 10, 0, 8); diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c index d675c49d1..1fe9f2279 100644 --- a/src/reset_rtc_screen.c +++ b/src/reset_rtc_screen.c @@ -142,7 +142,7 @@ static const union AnimCmd sSpriteAnim_85104CC[] = static const union AnimCmd sSpriteAnim_85104D4[] = { - ANIMCMD_FRAME(0, 158, .vFlip = TRUE), + ANIMCMD_FRAME(0, 30, .vFlip = TRUE), ANIMCMD_JUMP(0), }; diff --git a/src/roulette.c b/src/roulette.c index 25c079cda..5225118d5 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -3969,7 +3969,7 @@ static void sub_8144410(struct Sprite *sprite) if (!sub_8143B48(sprite)) { gUnknown_0203AB88->var90 = 0.0f; - gUnknown_0203AB88->var8C -= (float)(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var03) + gUnknown_0203AB88->var8C -= FLOAT_U8(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var03) / (gUnknown_085B6348[gUnknown_0203AB88->var04_0].var04 + 1); sprite->data[1] = 4; sprite->callback = sub_8144264; @@ -3994,8 +3994,8 @@ static void sub_8144514(struct Sprite *sprite) if (gUnknown_0203AB88->var94 > 40.f) return; - gUnknown_0203AB88->var98 = -(4.0f / (float)gUnknown_0203AB88->var86); - gUnknown_0203AB88->var90 = -(gUnknown_0203AB88->var8C / (float)gUnknown_0203AB88->var86); + gUnknown_0203AB88->var98 = -(4.0f / FLOAT_U16(gUnknown_0203AB88->var86)); + gUnknown_0203AB88->var90 = -(gUnknown_0203AB88->var8C / FLOAT_U16(gUnknown_0203AB88->var86)); sprite->animNum = 2; sprite->animBeginning = TRUE; sprite->animEnded = FALSE; @@ -4010,8 +4010,8 @@ static void sub_81445D8(struct Sprite *sprite) return; m4aSongNumStartOrChange(SE_TAMAKORO_E); - gUnknown_0203AB88->var98 = -(20.0f / (float)gUnknown_0203AB88->var84); - gUnknown_0203AB88->var90 = ((1.0f - gUnknown_0203AB88->var8C) / (float)gUnknown_0203AB88->var84); + gUnknown_0203AB88->var98 = -(20.0f / FLOAT_U16(gUnknown_0203AB88->var84)); + gUnknown_0203AB88->var90 = ((1.0f - gUnknown_0203AB88->var8C) / FLOAT_U16(gUnknown_0203AB88->var84)); sprite->animNum = 1; sprite->animBeginning = TRUE; sprite->animEnded = FALSE; diff --git a/src/roulette_util.c b/src/roulette_util.c index 9531302d9..16c3e8150 100755 --- a/src/roulette_util.c +++ b/src/roulette_util.c @@ -409,6 +409,7 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend) } break; case 2: // Flip back and forth + // This code is never reached if (pulseBlendPalette->fadeDirection) pulseBlendPalette->blendCoeff = 0; else diff --git a/src/save.c b/src/save.c index 45a75b5dc..cdfd2ae1d 100644 --- a/src/save.c +++ b/src/save.c @@ -626,7 +626,10 @@ static u16 CalculateChecksum(void *data, u16 size) u32 checksum = 0; for (i = 0; i < (size / 4); i++) - checksum += *((u32 *)data)++; + { + checksum += *((u32 *)data); + data += sizeof(u32); + } return ((checksum >> 16) + checksum); } diff --git a/src/scrcmd.c b/src/scrcmd.c index 8d597b887..57cd3edbe 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -62,7 +62,7 @@ static EWRAM_DATA u16 sMovingNpcMapBank = 0; static EWRAM_DATA u16 sMovingNpcMapId = 0; static EWRAM_DATA u16 sFieldEffectScriptId = 0; -IWRAM_DATA u8 gUnknown_03000F30; +static u8 gUnknown_03000F30; extern const SpecialFunc gSpecials[]; extern const u8 *gStdScripts[]; diff --git a/src/script_menu.c b/src/script_menu.c index 082253e35..b17d3df38 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -1017,8 +1017,8 @@ const u8 *const gUnknown_0858BBEC[] = EWRAM_DATA u8 gUnknown_02039F90 = 0; -IWRAM_DATA u8 gUnknown_03001124[7]; -IWRAM_DATA u32 filler_0300112c; +static u8 gUnknown_03001124[7]; +static u32 filler_0300112c; static void Task_HandleMultichoiceInput(u8); static void Task_HandleYesNoInput(u8); diff --git a/src/tv.c b/src/tv.c index dfd26fd0d..d696e1a21 100644 --- a/src/tv.c +++ b/src/tv.c @@ -56,9 +56,9 @@ struct { u16 move; } sTV_SecretBaseVisitMonsTemp[10]; -IWRAM_DATA u8 sTVShowMixingNumPlayers; -IWRAM_DATA u8 sTVShowNewsMixingNumPlayers; -IWRAM_DATA s8 sTVShowMixingCurSlot; +static u8 sTVShowMixingNumPlayers; +static u8 sTVShowNewsMixingNumPlayers; +static s8 sTVShowMixingCurSlot; EWRAM_DATA u16 sPokemonAnglerSpecies = 0; EWRAM_DATA u16 sPokemonAnglerAttemptCounters = 0; @@ -70,9 +70,6 @@ EWRAM_DATA u8 sTVSecretBaseSecretsRandomValues[3] = {}; // Static ROM declarations -extern const u8 *const sTVBravoTrainerTextGroup[]; -extern const u8 *const sTVBravoTrainerBattleTowerTextGroup[]; - void ClearPokemonNews(void); u8 GetTVChannelByShowType(u8 kind); u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void); diff --git a/src/union_room.c b/src/union_room.c index 6e7c0965d..486771af7 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -60,9 +60,9 @@ EWRAM_DATA u8 gUnknown_02022C3E = 0; EWRAM_DATA struct TradeUnkStruct gUnknown_02022C40 = {}; // IWRAM vars -IWRAM_DATA struct UnkStruct_Leader *gUnknown_03000DA0; -IWRAM_DATA struct UnkStruct_Group *gUnknown_03000DA4; -IWRAM_DATA struct UnkStruct_URoom *gUnknown_03000DA8; +static struct UnkStruct_Leader *gUnknown_03000DA0; +static struct UnkStruct_Group *gUnknown_03000DA4; +static struct UnkStruct_URoom *gUnknown_03000DA8; // this file's functions void sub_80173E0(u8 windowId, u8 arg1, const u8 *str, u8 arg3, u8 arg4, u8 arg5); diff --git a/src/union_room_battle.c b/src/union_room_battle.c index 321b49092..79d12291d 100644 --- a/src/union_room_battle.c +++ b/src/union_room_battle.c @@ -40,7 +40,7 @@ struct UnkStruct_2022C6C s16 a0; }; -IWRAM_DATA struct UnkStruct_3000DAC * gUnknown_03000DAC; +static struct UnkStruct_3000DAC * gUnknown_03000DAC; EWRAM_DATA struct UnkStruct_2022C6C * gUnknown_02022C6C = NULL; diff --git a/tools/gbafix/elf.h b/tools/gbafix/elf.h new file mode 100644 index 000000000..79d3b974b --- /dev/null +++ b/tools/gbafix/elf.h @@ -0,0 +1,3147 @@ +/* +From musl include/elf.h + +Copyright © 2005-2014 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef _ELF_H +#define _ELF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + +#define EI_NIDENT (16) + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr; + +#define EI_MAG0 0 +#define ELFMAG0 0x7f + +#define EI_MAG1 1 +#define ELFMAG1 'E' + +#define EI_MAG2 2 +#define ELFMAG2 'L' + +#define EI_MAG3 3 +#define ELFMAG3 'F' + + +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 +#define ELFCLASSNONE 0 +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define EI_DATA 5 +#define ELFDATANONE 0 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 +#define ELFDATANUM 3 + +#define EI_VERSION 6 + + +#define EI_OSABI 7 +#define ELFOSABI_NONE 0 +#define ELFOSABI_SYSV 0 +#define ELFOSABI_HPUX 1 +#define ELFOSABI_NETBSD 2 +#define ELFOSABI_LINUX 3 +#define ELFOSABI_GNU 3 +#define ELFOSABI_SOLARIS 6 +#define ELFOSABI_AIX 7 +#define ELFOSABI_IRIX 8 +#define ELFOSABI_FREEBSD 9 +#define ELFOSABI_TRU64 10 +#define ELFOSABI_MODESTO 11 +#define ELFOSABI_OPENBSD 12 +#define ELFOSABI_ARM 97 +#define ELFOSABI_STANDALONE 255 + +#define EI_ABIVERSION 8 + +#define EI_PAD 9 + + + +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_NUM 5 +#define ET_LOOS 0xfe00 +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 +#define ET_HIPROC 0xffff + + + +#define EM_NONE 0 +#define EM_M32 1 +#define EM_SPARC 2 +#define EM_386 3 +#define EM_68K 4 +#define EM_88K 5 +#define EM_860 7 +#define EM_MIPS 8 +#define EM_S370 9 +#define EM_MIPS_RS3_LE 10 + +#define EM_PARISC 15 +#define EM_VPP500 17 +#define EM_SPARC32PLUS 18 +#define EM_960 19 +#define EM_PPC 20 +#define EM_PPC64 21 +#define EM_S390 22 + +#define EM_V800 36 +#define EM_FR20 37 +#define EM_RH32 38 +#define EM_RCE 39 +#define EM_ARM 40 +#define EM_FAKE_ALPHA 41 +#define EM_SH 42 +#define EM_SPARCV9 43 +#define EM_TRICORE 44 +#define EM_ARC 45 +#define EM_H8_300 46 +#define EM_H8_300H 47 +#define EM_H8S 48 +#define EM_H8_500 49 +#define EM_IA_64 50 +#define EM_MIPS_X 51 +#define EM_COLDFIRE 52 +#define EM_68HC12 53 +#define EM_MMA 54 +#define EM_PCP 55 +#define EM_NCPU 56 +#define EM_NDR1 57 +#define EM_STARCORE 58 +#define EM_ME16 59 +#define EM_ST100 60 +#define EM_TINYJ 61 +#define EM_X86_64 62 +#define EM_PDSP 63 + +#define EM_FX66 66 +#define EM_ST9PLUS 67 +#define EM_ST7 68 +#define EM_68HC16 69 +#define EM_68HC11 70 +#define EM_68HC08 71 +#define EM_68HC05 72 +#define EM_SVX 73 +#define EM_ST19 74 +#define EM_VAX 75 +#define EM_CRIS 76 +#define EM_JAVELIN 77 +#define EM_FIREPATH 78 +#define EM_ZSP 79 +#define EM_MMIX 80 +#define EM_HUANY 81 +#define EM_PRISM 82 +#define EM_AVR 83 +#define EM_FR30 84 +#define EM_D10V 85 +#define EM_D30V 86 +#define EM_V850 87 +#define EM_M32R 88 +#define EM_MN10300 89 +#define EM_MN10200 90 +#define EM_PJ 91 +#define EM_OR1K 92 +#define EM_OPENRISC 92 +#define EM_ARC_A5 93 +#define EM_ARC_COMPACT 93 +#define EM_XTENSA 94 +#define EM_VIDEOCORE 95 +#define EM_TMM_GPP 96 +#define EM_NS32K 97 +#define EM_TPC 98 +#define EM_SNP1K 99 +#define EM_ST200 100 +#define EM_IP2K 101 +#define EM_MAX 102 +#define EM_CR 103 +#define EM_F2MC16 104 +#define EM_MSP430 105 +#define EM_BLACKFIN 106 +#define EM_SE_C33 107 +#define EM_SEP 108 +#define EM_ARCA 109 +#define EM_UNICORE 110 +#define EM_EXCESS 111 +#define EM_DXP 112 +#define EM_ALTERA_NIOS2 113 +#define EM_CRX 114 +#define EM_XGATE 115 +#define EM_C166 116 +#define EM_M16C 117 +#define EM_DSPIC30F 118 +#define EM_CE 119 +#define EM_M32C 120 +#define EM_TSK3000 131 +#define EM_RS08 132 +#define EM_SHARC 133 +#define EM_ECOG2 134 +#define EM_SCORE7 135 +#define EM_DSP24 136 +#define EM_VIDEOCORE3 137 +#define EM_LATTICEMICO32 138 +#define EM_SE_C17 139 +#define EM_TI_C6000 140 +#define EM_TI_C2000 141 +#define EM_TI_C5500 142 +#define EM_TI_ARP32 143 +#define EM_TI_PRU 144 +#define EM_MMDSP_PLUS 160 +#define EM_CYPRESS_M8C 161 +#define EM_R32C 162 +#define EM_TRIMEDIA 163 +#define EM_QDSP6 164 +#define EM_8051 165 +#define EM_STXP7X 166 +#define EM_NDS32 167 +#define EM_ECOG1X 168 +#define EM_MAXQ30 169 +#define EM_XIMO16 170 +#define EM_MANIK 171 +#define EM_CRAYNV2 172 +#define EM_RX 173 +#define EM_METAG 174 +#define EM_MCST_ELBRUS 175 +#define EM_ECOG16 176 +#define EM_CR16 177 +#define EM_ETPU 178 +#define EM_SLE9X 179 +#define EM_L10M 180 +#define EM_K10M 181 +#define EM_AARCH64 183 +#define EM_AVR32 185 +#define EM_STM8 186 +#define EM_TILE64 187 +#define EM_TILEPRO 188 +#define EM_MICROBLAZE 189 +#define EM_CUDA 190 +#define EM_TILEGX 191 +#define EM_CLOUDSHIELD 192 +#define EM_COREA_1ST 193 +#define EM_COREA_2ND 194 +#define EM_ARC_COMPACT2 195 +#define EM_OPEN8 196 +#define EM_RL78 197 +#define EM_VIDEOCORE5 198 +#define EM_78KOR 199 +#define EM_56800EX 200 +#define EM_BA1 201 +#define EM_BA2 202 +#define EM_XCORE 203 +#define EM_MCHP_PIC 204 +#define EM_KM32 210 +#define EM_KMX32 211 +#define EM_EMX16 212 +#define EM_EMX8 213 +#define EM_KVARC 214 +#define EM_CDP 215 +#define EM_COGE 216 +#define EM_COOL 217 +#define EM_NORC 218 +#define EM_CSR_KALIMBA 219 +#define EM_Z80 220 +#define EM_VISIUM 221 +#define EM_FT32 222 +#define EM_MOXIE 223 +#define EM_AMDGPU 224 +#define EM_RISCV 243 +#define EM_BPF 247 +#define EM_NUM 248 + +#define EM_ALPHA 0x9026 + +#define EV_NONE 0 +#define EV_CURRENT 1 +#define EV_NUM 2 + +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +typedef struct { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} Elf64_Shdr; + + + +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_BEFORE 0xff00 + +#define SHN_AFTER 0xff01 + +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 +#define SHN_HIOS 0xff3f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_XINDEX 0xffff +#define SHN_HIRESERVE 0xffff + + + +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_INIT_ARRAY 14 +#define SHT_FINI_ARRAY 15 +#define SHT_PREINIT_ARRAY 16 +#define SHT_GROUP 17 +#define SHT_SYMTAB_SHNDX 18 +#define SHT_NUM 19 +#define SHT_LOOS 0x60000000 +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 +#define SHT_GNU_HASH 0x6ffffff6 +#define SHT_GNU_LIBLIST 0x6ffffff7 +#define SHT_CHECKSUM 0x6ffffff8 +#define SHT_LOSUNW 0x6ffffffa +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd +#define SHT_GNU_verneed 0x6ffffffe +#define SHT_GNU_versym 0x6fffffff +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0x8fffffff + +#define SHF_WRITE (1 << 0) +#define SHF_ALLOC (1 << 1) +#define SHF_EXECINSTR (1 << 2) +#define SHF_MERGE (1 << 4) +#define SHF_STRINGS (1 << 5) +#define SHF_INFO_LINK (1 << 6) +#define SHF_LINK_ORDER (1 << 7) +#define SHF_OS_NONCONFORMING (1 << 8) + +#define SHF_GROUP (1 << 9) +#define SHF_TLS (1 << 10) +#define SHF_COMPRESSED (1 << 11) +#define SHF_MASKOS 0x0ff00000 +#define SHF_MASKPROC 0xf0000000 +#define SHF_ORDERED (1 << 30) +#define SHF_EXCLUDE (1U << 31) + +typedef struct { + Elf32_Word ch_type; + Elf32_Word ch_size; + Elf32_Word ch_addralign; +} Elf32_Chdr; + +typedef struct { + Elf64_Word ch_type; + Elf64_Word ch_reserved; + Elf64_Xword ch_size; + Elf64_Xword ch_addralign; +} Elf64_Chdr; + +#define ELFCOMPRESS_ZLIB 1 +#define ELFCOMPRESS_LOOS 0x60000000 +#define ELFCOMPRESS_HIOS 0x6fffffff +#define ELFCOMPRESS_LOPROC 0x70000000 +#define ELFCOMPRESS_HIPROC 0x7fffffff + + +#define GRP_COMDAT 0x1 + +typedef struct { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Section st_shndx; +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Section st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym; + +typedef struct { + Elf32_Half si_boundto; + Elf32_Half si_flags; +} Elf32_Syminfo; + +typedef struct { + Elf64_Half si_boundto; + Elf64_Half si_flags; +} Elf64_Syminfo; + +#define SYMINFO_BT_SELF 0xffff +#define SYMINFO_BT_PARENT 0xfffe +#define SYMINFO_BT_LOWRESERVE 0xff00 + +#define SYMINFO_FLG_DIRECT 0x0001 +#define SYMINFO_FLG_PASSTHRU 0x0002 +#define SYMINFO_FLG_COPY 0x0004 +#define SYMINFO_FLG_LAZYLOAD 0x0008 + +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_NUM 3 +#define STB_LOOS 10 +#define STB_GNU_UNIQUE 10 +#define STB_HIOS 12 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_COMMON 5 +#define STT_TLS 6 +#define STT_NUM 7 +#define STT_LOOS 10 +#define STT_GNU_IFUNC 10 +#define STT_HIOS 12 +#define STT_LOPROC 13 +#define STT_HIPROC 15 + +#define STN_UNDEF 0 + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +#define STV_DEFAULT 0 +#define STV_INTERNAL 1 +#define STV_HIDDEN 2 +#define STV_PROTECTED 3 + + + + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; +} Elf64_Rel; + + + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} Elf64_Rela; + + + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + + + +typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr; + + + +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_TLS 7 +#define PT_NUM 8 +#define PT_LOOS 0x60000000 +#define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_STACK 0x6474e551 +#define PT_GNU_RELRO 0x6474e552 +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa +#define PT_SUNWSTACK 0x6ffffffb +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff + + +#define PN_XNUM 0xffff + + +#define PF_X (1 << 0) +#define PF_W (1 << 1) +#define PF_R (1 << 2) +#define PF_MASKOS 0x0ff00000 +#define PF_MASKPROC 0xf0000000 + + + +#define NT_PRSTATUS 1 +#define NT_FPREGSET 2 +#define NT_PRPSINFO 3 +#define NT_PRXREG 4 +#define NT_TASKSTRUCT 4 +#define NT_PLATFORM 5 +#define NT_AUXV 6 +#define NT_GWINDOWS 7 +#define NT_ASRS 8 +#define NT_PSTATUS 10 +#define NT_PSINFO 13 +#define NT_PRCRED 14 +#define NT_UTSNAME 15 +#define NT_LWPSTATUS 16 +#define NT_LWPSINFO 17 +#define NT_PRFPXREG 20 +#define NT_SIGINFO 0x53494749 +#define NT_FILE 0x46494c45 +#define NT_PRXFPREG 0x46e62b7f +#define NT_PPC_VMX 0x100 +#define NT_PPC_SPE 0x101 +#define NT_PPC_VSX 0x102 +#define NT_386_TLS 0x200 +#define NT_386_IOPERM 0x201 +#define NT_X86_XSTATE 0x202 +#define NT_S390_HIGH_GPRS 0x300 +#define NT_S390_TIMER 0x301 +#define NT_S390_TODCMP 0x302 +#define NT_S390_TODPREG 0x303 +#define NT_S390_CTRS 0x304 +#define NT_S390_PREFIX 0x305 +#define NT_S390_LAST_BREAK 0x306 +#define NT_S390_SYSTEM_CALL 0x307 +#define NT_S390_TDB 0x308 +#define NT_ARM_VFP 0x400 +#define NT_ARM_TLS 0x401 +#define NT_ARM_HW_BREAK 0x402 +#define NT_ARM_HW_WATCH 0x403 +#define NT_ARM_SYSTEM_CALL 0x404 +#define NT_ARM_SVE 0x405 +#define NT_METAG_CBUF 0x500 +#define NT_METAG_RPIPE 0x501 +#define NT_METAG_TLS 0x502 +#define NT_VERSION 1 + + + + +typedef struct { + Elf32_Sword d_tag; + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Sxword d_tag; + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; +} Elf64_Dyn; + + + +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_BIND_NOW 24 +#define DT_INIT_ARRAY 25 +#define DT_FINI_ARRAY 26 +#define DT_INIT_ARRAYSZ 27 +#define DT_FINI_ARRAYSZ 28 +#define DT_RUNPATH 29 +#define DT_FLAGS 30 +#define DT_ENCODING 32 +#define DT_PREINIT_ARRAY 32 +#define DT_PREINIT_ARRAYSZ 33 +#define DT_NUM 34 +#define DT_LOOS 0x6000000d +#define DT_HIOS 0x6ffff000 +#define DT_LOPROC 0x70000000 +#define DT_HIPROC 0x7fffffff +#define DT_PROCNUM DT_MIPS_NUM + +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc +#define DT_POSFLAG_1 0x6ffffdfd + +#define DT_SYMINSZ 0x6ffffdfe +#define DT_SYMINENT 0x6ffffdff +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) +#define DT_VALNUM 12 + +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 +#define DT_TLSDESC_PLT 0x6ffffef6 +#define DT_TLSDESC_GOT 0x6ffffef7 +#define DT_GNU_CONFLICT 0x6ffffef8 +#define DT_GNU_LIBLIST 0x6ffffef9 +#define DT_CONFIG 0x6ffffefa +#define DT_DEPAUDIT 0x6ffffefb +#define DT_AUDIT 0x6ffffefc +#define DT_PLTPAD 0x6ffffefd +#define DT_MOVETAB 0x6ffffefe +#define DT_SYMINFO 0x6ffffeff +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) +#define DT_ADDRNUM 11 + + + +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + + +#define DT_FLAGS_1 0x6ffffffb +#define DT_VERDEF 0x6ffffffc + +#define DT_VERDEFNUM 0x6ffffffd +#define DT_VERNEED 0x6ffffffe + +#define DT_VERNEEDNUM 0x6fffffff +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) +#define DT_VERSIONTAGNUM 16 + + + +#define DT_AUXILIARY 0x7ffffffd +#define DT_FILTER 0x7fffffff +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + + +#define DF_ORIGIN 0x00000001 +#define DF_SYMBOLIC 0x00000002 +#define DF_TEXTREL 0x00000004 +#define DF_BIND_NOW 0x00000008 +#define DF_STATIC_TLS 0x00000010 + + + +#define DF_1_NOW 0x00000001 +#define DF_1_GLOBAL 0x00000002 +#define DF_1_GROUP 0x00000004 +#define DF_1_NODELETE 0x00000008 +#define DF_1_LOADFLTR 0x00000010 +#define DF_1_INITFIRST 0x00000020 +#define DF_1_NOOPEN 0x00000040 +#define DF_1_ORIGIN 0x00000080 +#define DF_1_DIRECT 0x00000100 +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 +#define DF_1_NODEFLIB 0x00000800 +#define DF_1_NODUMP 0x00001000 +#define DF_1_CONFALT 0x00002000 +#define DF_1_ENDFILTEE 0x00004000 +#define DF_1_DISPRELDNE 0x00008000 +#define DF_1_DISPRELPND 0x00010000 +#define DF_1_NODIRECT 0x00020000 +#define DF_1_IGNMULDEF 0x00040000 +#define DF_1_NOKSYMS 0x00080000 +#define DF_1_NOHDR 0x00100000 +#define DF_1_EDITED 0x00200000 +#define DF_1_NORELOC 0x00400000 +#define DF_1_SYMINTPOSE 0x00800000 +#define DF_1_GLOBAUDIT 0x01000000 +#define DF_1_SINGLETON 0x02000000 + +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + + +#define DF_P1_LAZYLOAD 0x00000001 +#define DF_P1_GROUPPERM 0x00000002 + + + + +typedef struct { + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} Elf32_Verdef; + +typedef struct { + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} Elf64_Verdef; + + + +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 +#define VER_DEF_NUM 2 + + +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + + +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_LORESERVE 0xff00 +#define VER_NDX_ELIMINATE 0xff01 + + + +typedef struct { + Elf32_Word vda_name; + Elf32_Word vda_next; +} Elf32_Verdaux; + +typedef struct { + Elf64_Word vda_name; + Elf64_Word vda_next; +} Elf64_Verdaux; + + + + +typedef struct { + Elf32_Half vn_version; + Elf32_Half vn_cnt; + Elf32_Word vn_file; + Elf32_Word vn_aux; + Elf32_Word vn_next; +} Elf32_Verneed; + +typedef struct { + Elf64_Half vn_version; + Elf64_Half vn_cnt; + Elf64_Word vn_file; + Elf64_Word vn_aux; + Elf64_Word vn_next; +} Elf64_Verneed; + + + +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 +#define VER_NEED_NUM 2 + + + +typedef struct { + Elf32_Word vna_hash; + Elf32_Half vna_flags; + Elf32_Half vna_other; + Elf32_Word vna_name; + Elf32_Word vna_next; +} Elf32_Vernaux; + +typedef struct { + Elf64_Word vna_hash; + Elf64_Half vna_flags; + Elf64_Half vna_other; + Elf64_Word vna_name; + Elf64_Word vna_next; +} Elf64_Vernaux; + + + +#define VER_FLG_WEAK 0x2 + + + +typedef struct { + uint32_t a_type; + union { + uint32_t a_val; + } a_un; +} Elf32_auxv_t; + +typedef struct { + uint64_t a_type; + union { + uint64_t a_val; + } a_un; +} Elf64_auxv_t; + + + +#define AT_NULL 0 +#define AT_IGNORE 1 +#define AT_EXECFD 2 +#define AT_PHDR 3 +#define AT_PHENT 4 +#define AT_PHNUM 5 +#define AT_PAGESZ 6 +#define AT_BASE 7 +#define AT_FLAGS 8 +#define AT_ENTRY 9 +#define AT_NOTELF 10 +#define AT_UID 11 +#define AT_EUID 12 +#define AT_GID 13 +#define AT_EGID 14 +#define AT_CLKTCK 17 + + +#define AT_PLATFORM 15 +#define AT_HWCAP 16 + + + + +#define AT_FPUCW 18 + + +#define AT_DCACHEBSIZE 19 +#define AT_ICACHEBSIZE 20 +#define AT_UCACHEBSIZE 21 + + + +#define AT_IGNOREPPC 22 + +#define AT_SECURE 23 + +#define AT_BASE_PLATFORM 24 + +#define AT_RANDOM 25 + +#define AT_HWCAP2 26 + +#define AT_EXECFN 31 + + + +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 + + + +#define AT_L1I_CACHESHAPE 34 +#define AT_L1D_CACHESHAPE 35 +#define AT_L2_CACHESHAPE 36 +#define AT_L3_CACHESHAPE 37 + + + + +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} Elf64_Nhdr; + + + + +#define ELF_NOTE_SOLARIS "SUNW Solaris" + + +#define ELF_NOTE_GNU "GNU" + + + + + +#define ELF_NOTE_PAGESIZE_HINT 1 + + +#define NT_GNU_ABI_TAG 1 +#define ELF_NOTE_ABI NT_GNU_ABI_TAG + + + +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 +#define ELF_NOTE_OS_FREEBSD 3 + +#define NT_GNU_BUILD_ID 3 +#define NT_GNU_GOLD_VERSION 4 + + + +typedef struct { + Elf32_Xword m_value; + Elf32_Word m_info; + Elf32_Word m_poffset; + Elf32_Half m_repeat; + Elf32_Half m_stride; +} Elf32_Move; + +typedef struct { + Elf64_Xword m_value; + Elf64_Xword m_info; + Elf64_Xword m_poffset; + Elf64_Half m_repeat; + Elf64_Half m_stride; +} Elf64_Move; + + +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + +#define EF_CPU32 0x00810000 + +#define R_68K_NONE 0 +#define R_68K_32 1 +#define R_68K_16 2 +#define R_68K_8 3 +#define R_68K_PC32 4 +#define R_68K_PC16 5 +#define R_68K_PC8 6 +#define R_68K_GOT32 7 +#define R_68K_GOT16 8 +#define R_68K_GOT8 9 +#define R_68K_GOT32O 10 +#define R_68K_GOT16O 11 +#define R_68K_GOT8O 12 +#define R_68K_PLT32 13 +#define R_68K_PLT16 14 +#define R_68K_PLT8 15 +#define R_68K_PLT32O 16 +#define R_68K_PLT16O 17 +#define R_68K_PLT8O 18 +#define R_68K_COPY 19 +#define R_68K_GLOB_DAT 20 +#define R_68K_JMP_SLOT 21 +#define R_68K_RELATIVE 22 +#define R_68K_NUM 23 + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 +#define R_386_SIZE32 38 +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 +#define R_386_IRELATIVE 42 +#define R_386_GOT32X 43 +#define R_386_NUM 44 + + + + + +#define STT_SPARC_REGISTER 13 + + + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 +#define EF_SPARC_SUN_US1 0x000200 +#define EF_SPARC_HAL_R1 0x000400 +#define EF_SPARC_SUN_US3 0x000800 + + + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 + + + +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +#define R_SPARC_GOTDATA_HIX22 80 +#define R_SPARC_GOTDATA_LOX10 81 +#define R_SPARC_GOTDATA_OP_HIX22 82 +#define R_SPARC_GOTDATA_OP_LOX10 83 +#define R_SPARC_GOTDATA_OP 84 +#define R_SPARC_H34 85 +#define R_SPARC_SIZE32 86 +#define R_SPARC_SIZE64 87 +#define R_SPARC_GNU_VTINHERIT 250 +#define R_SPARC_GNU_VTENTRY 251 +#define R_SPARC_REV32 252 + +#define R_SPARC_NUM 253 + + + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + + +#define EF_MIPS_NOREORDER 1 +#define EF_MIPS_PIC 2 +#define EF_MIPS_CPIC 4 +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_FP64 512 +#define EF_MIPS_NAN2008 1024 +#define EF_MIPS_ARCH 0xf0000000 + + + +#define EF_MIPS_ARCH_1 0x00000000 +#define EF_MIPS_ARCH_2 0x10000000 +#define EF_MIPS_ARCH_3 0x20000000 +#define EF_MIPS_ARCH_4 0x30000000 +#define EF_MIPS_ARCH_5 0x40000000 +#define EF_MIPS_ARCH_32 0x50000000 +#define EF_MIPS_ARCH_64 0x60000000 +#define EF_MIPS_ARCH_32R2 0x70000000 +#define EF_MIPS_ARCH_64R2 0x80000000 + + +#define E_MIPS_ARCH_1 0x00000000 +#define E_MIPS_ARCH_2 0x10000000 +#define E_MIPS_ARCH_3 0x20000000 +#define E_MIPS_ARCH_4 0x30000000 +#define E_MIPS_ARCH_5 0x40000000 +#define E_MIPS_ARCH_32 0x50000000 +#define E_MIPS_ARCH_64 0x60000000 + + + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 +#define SHN_MIPS_SUNDEFINED 0xff04 + + + +#define SHT_MIPS_LIBLIST 0x70000000 +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 +#define SHT_MIPS_GPTAB 0x70000003 +#define SHT_MIPS_UCODE 0x70000004 +#define SHT_MIPS_DEBUG 0x70000005 +#define SHT_MIPS_REGINFO 0x70000006 +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + + + +#define SHF_MIPS_GPREL 0x10000000 +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + + + + +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_PLT 0x8 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + + +#define STB_MIPS_SPLIT_COMMON 13 + + + +typedef union { + struct { + Elf32_Word gt_current_g_value; + Elf32_Word gt_unused; + } gt_header; + struct { + Elf32_Word gt_g_value; + Elf32_Word gt_bytes; + } gt_entry; +} Elf32_gptab; + + + +typedef struct { + Elf32_Word ri_gprmask; + Elf32_Word ri_cprmask[4]; + Elf32_Sword ri_gp_value; +} Elf32_RegInfo; + + + +typedef struct { + unsigned char kind; + + unsigned char size; + Elf32_Section section; + + Elf32_Word info; +} Elf_Options; + + + +#define ODK_NULL 0 +#define ODK_REGINFO 1 +#define ODK_EXCEPTIONS 2 +#define ODK_PAD 3 +#define ODK_HWPATCH 4 +#define ODK_FILL 5 +#define ODK_TAGS 6 +#define ODK_HWAND 7 +#define ODK_HWOR 8 + + + +#define OEX_FPU_MIN 0x1f +#define OEX_FPU_MAX 0x1f00 +#define OEX_PAGE0 0x10000 +#define OEX_SMM 0x20000 +#define OEX_FPDBUG 0x40000 +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + + + +#define OHW_R4KEOP 0x1 +#define OHW_R8KPFETCH 0x2 +#define OHW_R5KEOP 0x4 +#define OHW_R5KCVTL 0x8 + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + + + +typedef struct { + Elf32_Word hwp_flags1; + Elf32_Word hwp_flags2; +} Elf_Options_Hw; + + + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + + + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 +#define R_MIPS_GPREL16 7 +#define R_MIPS_LITERAL 8 +#define R_MIPS_GOT16 9 +#define R_MIPS_PC16 10 +#define R_MIPS_CALL16 11 +#define R_MIPS_GPREL32 12 + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_DTPMOD32 38 +#define R_MIPS_TLS_DTPREL32 39 +#define R_MIPS_TLS_DTPMOD64 40 +#define R_MIPS_TLS_DTPREL64 41 +#define R_MIPS_TLS_GD 42 +#define R_MIPS_TLS_LDM 43 +#define R_MIPS_TLS_DTPREL_HI16 44 +#define R_MIPS_TLS_DTPREL_LO16 45 +#define R_MIPS_TLS_GOTTPREL 46 +#define R_MIPS_TLS_TPREL32 47 +#define R_MIPS_TLS_TPREL64 48 +#define R_MIPS_TLS_TPREL_HI16 49 +#define R_MIPS_TLS_TPREL_LO16 50 +#define R_MIPS_GLOB_DAT 51 +#define R_MIPS_COPY 126 +#define R_MIPS_JUMP_SLOT 127 + +#define R_MIPS_NUM 128 + + + +#define PT_MIPS_REGINFO 0x70000000 +#define PT_MIPS_RTPROC 0x70000001 +#define PT_MIPS_OPTIONS 0x70000002 +#define PT_MIPS_ABIFLAGS 0x70000003 + + + +#define PF_MIPS_LOCAL 0x10000000 + + + +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_LOCAL_GOTNO 0x7000000a +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 +#define DT_MIPS_DELTA_CLASS 0x70000017 +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 + +#define DT_MIPS_DELTA_INSTANCE 0x70000019 +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a + +#define DT_MIPS_DELTA_RELOC 0x7000001b +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c + +#define DT_MIPS_DELTA_SYM 0x7000001d + +#define DT_MIPS_DELTA_SYM_NO 0x7000001e + +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 + +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 + +#define DT_MIPS_CXX_FLAGS 0x70000022 +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 +#define DT_MIPS_INTERFACE 0x7000002a +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d + +#define DT_MIPS_PERF_SUFFIX 0x7000002e + +#define DT_MIPS_COMPACT_SIZE 0x7000002f +#define DT_MIPS_GP_VALUE 0x70000030 +#define DT_MIPS_AUX_DYNAMIC 0x70000031 + +#define DT_MIPS_PLTGOT 0x70000032 + +#define DT_MIPS_RWPLT 0x70000034 +#define DT_MIPS_RLD_MAP_REL 0x70000035 +#define DT_MIPS_NUM 0x36 + + + +#define RHF_NONE 0 +#define RHF_QUICKSTART (1 << 0) +#define RHF_NOTPOT (1 << 1) +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + + + +typedef struct { + Elf32_Word l_name; + Elf32_Word l_time_stamp; + Elf32_Word l_checksum; + Elf32_Word l_version; + Elf32_Word l_flags; +} Elf32_Lib; + +typedef struct { + Elf64_Word l_name; + Elf64_Word l_time_stamp; + Elf64_Word l_checksum; + Elf64_Word l_version; + Elf64_Word l_flags; +} Elf64_Lib; + + + + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) +#define LL_IGNORE_INT_VER (1 << 1) +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + + + +typedef Elf32_Addr Elf32_Conflict; + +typedef struct { + Elf32_Half version; + unsigned char isa_level; + unsigned char isa_rev; + unsigned char gpr_size; + unsigned char cpr1_size; + unsigned char cpr2_size; + unsigned char fp_abi; + Elf32_Word isa_ext; + Elf32_Word ases; + Elf32_Word flags1; + Elf32_Word flags2; +} Elf_MIPS_ABIFlags_v0; + +#define MIPS_AFL_REG_NONE 0x00 +#define MIPS_AFL_REG_32 0x01 +#define MIPS_AFL_REG_64 0x02 +#define MIPS_AFL_REG_128 0x03 + +#define MIPS_AFL_ASE_DSP 0x00000001 +#define MIPS_AFL_ASE_DSPR2 0x00000002 +#define MIPS_AFL_ASE_EVA 0x00000004 +#define MIPS_AFL_ASE_MCU 0x00000008 +#define MIPS_AFL_ASE_MDMX 0x00000010 +#define MIPS_AFL_ASE_MIPS3D 0x00000020 +#define MIPS_AFL_ASE_MT 0x00000040 +#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 +#define MIPS_AFL_ASE_VIRT 0x00000100 +#define MIPS_AFL_ASE_MSA 0x00000200 +#define MIPS_AFL_ASE_MIPS16 0x00000400 +#define MIPS_AFL_ASE_MICROMIPS 0x00000800 +#define MIPS_AFL_ASE_XPA 0x00001000 +#define MIPS_AFL_ASE_MASK 0x00001fff + +#define MIPS_AFL_EXT_XLR 1 +#define MIPS_AFL_EXT_OCTEON2 2 +#define MIPS_AFL_EXT_OCTEONP 3 +#define MIPS_AFL_EXT_LOONGSON_3A 4 +#define MIPS_AFL_EXT_OCTEON 5 +#define MIPS_AFL_EXT_5900 6 +#define MIPS_AFL_EXT_4650 7 +#define MIPS_AFL_EXT_4010 8 +#define MIPS_AFL_EXT_4100 9 +#define MIPS_AFL_EXT_3900 10 +#define MIPS_AFL_EXT_10000 11 +#define MIPS_AFL_EXT_SB1 12 +#define MIPS_AFL_EXT_4111 13 +#define MIPS_AFL_EXT_4120 14 +#define MIPS_AFL_EXT_5400 15 +#define MIPS_AFL_EXT_5500 16 +#define MIPS_AFL_EXT_LOONGSON_2E 17 +#define MIPS_AFL_EXT_LOONGSON_2F 18 + +#define MIPS_AFL_FLAGS1_ODDSPREG 1 + +enum +{ + Val_GNU_MIPS_ABI_FP_ANY = 0, + Val_GNU_MIPS_ABI_FP_DOUBLE = 1, + Val_GNU_MIPS_ABI_FP_SINGLE = 2, + Val_GNU_MIPS_ABI_FP_SOFT = 3, + Val_GNU_MIPS_ABI_FP_OLD_64 = 4, + Val_GNU_MIPS_ABI_FP_XX = 5, + Val_GNU_MIPS_ABI_FP_64 = 6, + Val_GNU_MIPS_ABI_FP_64A = 7, + Val_GNU_MIPS_ABI_FP_MAX = 7 +}; + + + + +#define EF_PARISC_TRAPNIL 0x00010000 +#define EF_PARISC_EXT 0x00020000 +#define EF_PARISC_LSB 0x00040000 +#define EF_PARISC_WIDE 0x00080000 +#define EF_PARISC_NO_KABP 0x00100000 + +#define EF_PARISC_LAZYSWAP 0x00400000 +#define EF_PARISC_ARCH 0x0000ffff + + + +#define EFA_PARISC_1_0 0x020b +#define EFA_PARISC_1_1 0x0210 +#define EFA_PARISC_2_0 0x0214 + + + +#define SHN_PARISC_ANSI_COMMON 0xff00 + +#define SHN_PARISC_HUGE_COMMON 0xff01 + + + +#define SHT_PARISC_EXT 0x70000000 +#define SHT_PARISC_UNWIND 0x70000001 +#define SHT_PARISC_DOC 0x70000002 + + + +#define SHF_PARISC_SHORT 0x20000000 +#define SHF_PARISC_HUGE 0x40000000 +#define SHF_PARISC_SBP 0x80000000 + + + +#define STT_PARISC_MILLICODE 13 + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + + + +#define R_PARISC_NONE 0 +#define R_PARISC_DIR32 1 +#define R_PARISC_DIR21L 2 +#define R_PARISC_DIR17R 3 +#define R_PARISC_DIR17F 4 +#define R_PARISC_DIR14R 6 +#define R_PARISC_PCREL32 9 +#define R_PARISC_PCREL21L 10 +#define R_PARISC_PCREL17R 11 +#define R_PARISC_PCREL17F 12 +#define R_PARISC_PCREL14R 14 +#define R_PARISC_DPREL21L 18 +#define R_PARISC_DPREL14R 22 +#define R_PARISC_GPREL21L 26 +#define R_PARISC_GPREL14R 30 +#define R_PARISC_LTOFF21L 34 +#define R_PARISC_LTOFF14R 38 +#define R_PARISC_SECREL32 41 +#define R_PARISC_SEGBASE 48 +#define R_PARISC_SEGREL32 49 +#define R_PARISC_PLTOFF21L 50 +#define R_PARISC_PLTOFF14R 54 +#define R_PARISC_LTOFF_FPTR32 57 +#define R_PARISC_LTOFF_FPTR21L 58 +#define R_PARISC_LTOFF_FPTR14R 62 +#define R_PARISC_FPTR64 64 +#define R_PARISC_PLABEL32 65 +#define R_PARISC_PLABEL21L 66 +#define R_PARISC_PLABEL14R 70 +#define R_PARISC_PCREL64 72 +#define R_PARISC_PCREL22F 74 +#define R_PARISC_PCREL14WR 75 +#define R_PARISC_PCREL14DR 76 +#define R_PARISC_PCREL16F 77 +#define R_PARISC_PCREL16WF 78 +#define R_PARISC_PCREL16DF 79 +#define R_PARISC_DIR64 80 +#define R_PARISC_DIR14WR 83 +#define R_PARISC_DIR14DR 84 +#define R_PARISC_DIR16F 85 +#define R_PARISC_DIR16WF 86 +#define R_PARISC_DIR16DF 87 +#define R_PARISC_GPREL64 88 +#define R_PARISC_GPREL14WR 91 +#define R_PARISC_GPREL14DR 92 +#define R_PARISC_GPREL16F 93 +#define R_PARISC_GPREL16WF 94 +#define R_PARISC_GPREL16DF 95 +#define R_PARISC_LTOFF64 96 +#define R_PARISC_LTOFF14WR 99 +#define R_PARISC_LTOFF14DR 100 +#define R_PARISC_LTOFF16F 101 +#define R_PARISC_LTOFF16WF 102 +#define R_PARISC_LTOFF16DF 103 +#define R_PARISC_SECREL64 104 +#define R_PARISC_SEGREL64 112 +#define R_PARISC_PLTOFF14WR 115 +#define R_PARISC_PLTOFF14DR 116 +#define R_PARISC_PLTOFF16F 117 +#define R_PARISC_PLTOFF16WF 118 +#define R_PARISC_PLTOFF16DF 119 +#define R_PARISC_LTOFF_FPTR64 120 +#define R_PARISC_LTOFF_FPTR14WR 123 +#define R_PARISC_LTOFF_FPTR14DR 124 +#define R_PARISC_LTOFF_FPTR16F 125 +#define R_PARISC_LTOFF_FPTR16WF 126 +#define R_PARISC_LTOFF_FPTR16DF 127 +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 +#define R_PARISC_IPLT 129 +#define R_PARISC_EPLT 130 +#define R_PARISC_TPREL32 153 +#define R_PARISC_TPREL21L 154 +#define R_PARISC_TPREL14R 158 +#define R_PARISC_LTOFF_TP21L 162 +#define R_PARISC_LTOFF_TP14R 166 +#define R_PARISC_LTOFF_TP14F 167 +#define R_PARISC_TPREL64 216 +#define R_PARISC_TPREL14WR 219 +#define R_PARISC_TPREL14DR 220 +#define R_PARISC_TPREL16F 221 +#define R_PARISC_TPREL16WF 222 +#define R_PARISC_TPREL16DF 223 +#define R_PARISC_LTOFF_TP64 224 +#define R_PARISC_LTOFF_TP14WR 227 +#define R_PARISC_LTOFF_TP14DR 228 +#define R_PARISC_LTOFF_TP16F 229 +#define R_PARISC_LTOFF_TP16WF 230 +#define R_PARISC_LTOFF_TP16DF 231 +#define R_PARISC_GNU_VTENTRY 232 +#define R_PARISC_GNU_VTINHERIT 233 +#define R_PARISC_TLS_GD21L 234 +#define R_PARISC_TLS_GD14R 235 +#define R_PARISC_TLS_GDCALL 236 +#define R_PARISC_TLS_LDM21L 237 +#define R_PARISC_TLS_LDM14R 238 +#define R_PARISC_TLS_LDMCALL 239 +#define R_PARISC_TLS_LDO21L 240 +#define R_PARISC_TLS_LDO14R 241 +#define R_PARISC_TLS_DTPMOD32 242 +#define R_PARISC_TLS_DTPMOD64 243 +#define R_PARISC_TLS_DTPOFF32 244 +#define R_PARISC_TLS_DTPOFF64 245 +#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L +#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R +#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L +#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R +#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32 +#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64 +#define R_PARISC_HIRESERVE 255 + + + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + + + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + + + + + +#define EF_ALPHA_32BIT 1 +#define EF_ALPHA_CANRELAX 2 + + + + +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + + + +#define SHF_ALPHA_GPREL 0x10000000 + + +#define STO_ALPHA_NOPV 0x80 +#define STO_ALPHA_STD_GPLOAD 0x88 + + + +#define R_ALPHA_NONE 0 +#define R_ALPHA_REFLONG 1 +#define R_ALPHA_REFQUAD 2 +#define R_ALPHA_GPREL32 3 +#define R_ALPHA_LITERAL 4 +#define R_ALPHA_LITUSE 5 +#define R_ALPHA_GPDISP 6 +#define R_ALPHA_BRADDR 7 +#define R_ALPHA_HINT 8 +#define R_ALPHA_SREL16 9 +#define R_ALPHA_SREL32 10 +#define R_ALPHA_SREL64 11 +#define R_ALPHA_GPRELHIGH 17 +#define R_ALPHA_GPRELLOW 18 +#define R_ALPHA_GPREL16 19 +#define R_ALPHA_COPY 24 +#define R_ALPHA_GLOB_DAT 25 +#define R_ALPHA_JMP_SLOT 26 +#define R_ALPHA_RELATIVE 27 +#define R_ALPHA_TLS_GD_HI 28 +#define R_ALPHA_TLSGD 29 +#define R_ALPHA_TLS_LDM 30 +#define R_ALPHA_DTPMOD64 31 +#define R_ALPHA_GOTDTPREL 32 +#define R_ALPHA_DTPREL64 33 +#define R_ALPHA_DTPRELHI 34 +#define R_ALPHA_DTPRELLO 35 +#define R_ALPHA_DTPREL16 36 +#define R_ALPHA_GOTTPREL 37 +#define R_ALPHA_TPREL64 38 +#define R_ALPHA_TPRELHI 39 +#define R_ALPHA_TPRELLO 40 +#define R_ALPHA_TPREL16 41 + +#define R_ALPHA_NUM 46 + + +#define LITUSE_ALPHA_ADDR 0 +#define LITUSE_ALPHA_BASE 1 +#define LITUSE_ALPHA_BYTOFF 2 +#define LITUSE_ALPHA_JSR 3 +#define LITUSE_ALPHA_TLS_GD 4 +#define LITUSE_ALPHA_TLS_LDM 5 + + +#define DT_ALPHA_PLTRO (DT_LOPROC + 0) +#define DT_ALPHA_NUM 1 + + + + +#define EF_PPC_EMB 0x80000000 + + +#define EF_PPC_RELOCATABLE 0x00010000 +#define EF_PPC_RELOCATABLE_LIB 0x00008000 + + + +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + + +#define R_PPC_TLS 67 +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 +#define R_PPC_GOT_DTPREL16 91 +#define R_PPC_GOT_DTPREL16_LO 92 +#define R_PPC_GOT_DTPREL16_HI 93 +#define R_PPC_GOT_DTPREL16_HA 94 +#define R_PPC_TLSGD 95 +#define R_PPC_TLSLD 96 + + +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + + +#define R_PPC_DIAB_SDA21_LO 180 +#define R_PPC_DIAB_SDA21_HI 181 +#define R_PPC_DIAB_SDA21_HA 182 +#define R_PPC_DIAB_RELSDA_LO 183 +#define R_PPC_DIAB_RELSDA_HI 184 +#define R_PPC_DIAB_RELSDA_HA 185 + + +#define R_PPC_IRELATIVE 248 + + +#define R_PPC_REL16 249 +#define R_PPC_REL16_LO 250 +#define R_PPC_REL16_HI 251 +#define R_PPC_REL16_HA 252 + + + +#define R_PPC_TOC16 255 + + +#define DT_PPC_GOT (DT_LOPROC + 0) +#define DT_PPC_OPT (DT_LOPROC + 1) +#define DT_PPC_NUM 2 + +#define PPC_OPT_TLS 1 + + +#define R_PPC64_NONE R_PPC_NONE +#define R_PPC64_ADDR32 R_PPC_ADDR32 +#define R_PPC64_ADDR24 R_PPC_ADDR24 +#define R_PPC64_ADDR16 R_PPC_ADDR16 +#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO +#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI +#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA +#define R_PPC64_ADDR14 R_PPC_ADDR14 +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN +#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN +#define R_PPC64_REL24 R_PPC_REL24 +#define R_PPC64_REL14 R_PPC_REL14 +#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN +#define R_PPC64_GOT16 R_PPC_GOT16 +#define R_PPC64_GOT16_LO R_PPC_GOT16_LO +#define R_PPC64_GOT16_HI R_PPC_GOT16_HI +#define R_PPC64_GOT16_HA R_PPC_GOT16_HA + +#define R_PPC64_COPY R_PPC_COPY +#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT +#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT +#define R_PPC64_RELATIVE R_PPC_RELATIVE + +#define R_PPC64_UADDR32 R_PPC_UADDR32 +#define R_PPC64_UADDR16 R_PPC_UADDR16 +#define R_PPC64_REL32 R_PPC_REL32 +#define R_PPC64_PLT32 R_PPC_PLT32 +#define R_PPC64_PLTREL32 R_PPC_PLTREL32 +#define R_PPC64_PLT16_LO R_PPC_PLT16_LO +#define R_PPC64_PLT16_HI R_PPC_PLT16_HI +#define R_PPC64_PLT16_HA R_PPC_PLT16_HA + +#define R_PPC64_SECTOFF R_PPC_SECTOFF +#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO +#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI +#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA +#define R_PPC64_ADDR30 37 +#define R_PPC64_ADDR64 38 +#define R_PPC64_ADDR16_HIGHER 39 +#define R_PPC64_ADDR16_HIGHERA 40 +#define R_PPC64_ADDR16_HIGHEST 41 +#define R_PPC64_ADDR16_HIGHESTA 42 +#define R_PPC64_UADDR64 43 +#define R_PPC64_REL64 44 +#define R_PPC64_PLT64 45 +#define R_PPC64_PLTREL64 46 +#define R_PPC64_TOC16 47 +#define R_PPC64_TOC16_LO 48 +#define R_PPC64_TOC16_HI 49 +#define R_PPC64_TOC16_HA 50 +#define R_PPC64_TOC 51 +#define R_PPC64_PLTGOT16 52 +#define R_PPC64_PLTGOT16_LO 53 +#define R_PPC64_PLTGOT16_HI 54 +#define R_PPC64_PLTGOT16_HA 55 + +#define R_PPC64_ADDR16_DS 56 +#define R_PPC64_ADDR16_LO_DS 57 +#define R_PPC64_GOT16_DS 58 +#define R_PPC64_GOT16_LO_DS 59 +#define R_PPC64_PLT16_LO_DS 60 +#define R_PPC64_SECTOFF_DS 61 +#define R_PPC64_SECTOFF_LO_DS 62 +#define R_PPC64_TOC16_DS 63 +#define R_PPC64_TOC16_LO_DS 64 +#define R_PPC64_PLTGOT16_DS 65 +#define R_PPC64_PLTGOT16_LO_DS 66 + + +#define R_PPC64_TLS 67 +#define R_PPC64_DTPMOD64 68 +#define R_PPC64_TPREL16 69 +#define R_PPC64_TPREL16_LO 70 +#define R_PPC64_TPREL16_HI 71 +#define R_PPC64_TPREL16_HA 72 +#define R_PPC64_TPREL64 73 +#define R_PPC64_DTPREL16 74 +#define R_PPC64_DTPREL16_LO 75 +#define R_PPC64_DTPREL16_HI 76 +#define R_PPC64_DTPREL16_HA 77 +#define R_PPC64_DTPREL64 78 +#define R_PPC64_GOT_TLSGD16 79 +#define R_PPC64_GOT_TLSGD16_LO 80 +#define R_PPC64_GOT_TLSGD16_HI 81 +#define R_PPC64_GOT_TLSGD16_HA 82 +#define R_PPC64_GOT_TLSLD16 83 +#define R_PPC64_GOT_TLSLD16_LO 84 +#define R_PPC64_GOT_TLSLD16_HI 85 +#define R_PPC64_GOT_TLSLD16_HA 86 +#define R_PPC64_GOT_TPREL16_DS 87 +#define R_PPC64_GOT_TPREL16_LO_DS 88 +#define R_PPC64_GOT_TPREL16_HI 89 +#define R_PPC64_GOT_TPREL16_HA 90 +#define R_PPC64_GOT_DTPREL16_DS 91 +#define R_PPC64_GOT_DTPREL16_LO_DS 92 +#define R_PPC64_GOT_DTPREL16_HI 93 +#define R_PPC64_GOT_DTPREL16_HA 94 +#define R_PPC64_TPREL16_DS 95 +#define R_PPC64_TPREL16_LO_DS 96 +#define R_PPC64_TPREL16_HIGHER 97 +#define R_PPC64_TPREL16_HIGHERA 98 +#define R_PPC64_TPREL16_HIGHEST 99 +#define R_PPC64_TPREL16_HIGHESTA 100 +#define R_PPC64_DTPREL16_DS 101 +#define R_PPC64_DTPREL16_LO_DS 102 +#define R_PPC64_DTPREL16_HIGHER 103 +#define R_PPC64_DTPREL16_HIGHERA 104 +#define R_PPC64_DTPREL16_HIGHEST 105 +#define R_PPC64_DTPREL16_HIGHESTA 106 +#define R_PPC64_TLSGD 107 +#define R_PPC64_TLSLD 108 +#define R_PPC64_TOCSAVE 109 +#define R_PPC64_ADDR16_HIGH 110 +#define R_PPC64_ADDR16_HIGHA 111 +#define R_PPC64_TPREL16_HIGH 112 +#define R_PPC64_TPREL16_HIGHA 113 +#define R_PPC64_DTPREL16_HIGH 114 +#define R_PPC64_DTPREL16_HIGHA 115 + + +#define R_PPC64_JMP_IREL 247 +#define R_PPC64_IRELATIVE 248 +#define R_PPC64_REL16 249 +#define R_PPC64_REL16_LO 250 +#define R_PPC64_REL16_HI 251 +#define R_PPC64_REL16_HA 252 + +#define EF_PPC64_ABI 3 + +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_OPD (DT_LOPROC + 1) +#define DT_PPC64_OPDSZ (DT_LOPROC + 2) +#define DT_PPC64_OPT (DT_LOPROC + 3) +#define DT_PPC64_NUM 4 + +#define PPC64_OPT_TLS 1 +#define PPC64_OPT_MULTI_TOC 2 + +#define STO_PPC64_LOCAL_BIT 5 +#define STO_PPC64_LOCAL_MASK 0xe0 +#define PPC64_LOCAL_ENTRY_OFFSET(x) (1 << (((x)&0xe0)>>5) & 0xfc) + + +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 +#define EF_ARM_SOFT_FLOAT 0x200 +#define EF_ARM_VFP_FLOAT 0x400 +#define EF_ARM_MAVERICK_FLOAT 0x800 + +#define EF_ARM_ABI_FLOAT_SOFT 0x200 +#define EF_ARM_ABI_FLOAT_HARD 0x400 + + +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + + +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_LE8 0x00400000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + + +#define STT_ARM_TFUNC STT_LOPROC +#define STT_ARM_16BIT STT_HIPROC + + +#define SHF_ARM_ENTRYSECT 0x10000000 +#define SHF_ARM_COMDEF 0x80000000 + + + +#define PF_ARM_SB 0x10000000 + +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ABS 0x40000000 + + +#define PT_ARM_EXIDX (PT_LOPROC + 1) + + +#define SHT_ARM_EXIDX (SHT_LOPROC + 1) +#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) +#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) + +#define R_AARCH64_NONE 0 +#define R_AARCH64_P32_ABS32 1 +#define R_AARCH64_P32_COPY 180 +#define R_AARCH64_P32_GLOB_DAT 181 +#define R_AARCH64_P32_JUMP_SLOT 182 +#define R_AARCH64_P32_RELATIVE 183 +#define R_AARCH64_P32_TLS_DTPMOD 184 +#define R_AARCH64_P32_TLS_DTPREL 185 +#define R_AARCH64_P32_TLS_TPREL 186 +#define R_AARCH64_P32_TLSDESC 187 +#define R_AARCH64_P32_IRELATIVE 188 +#define R_AARCH64_ABS64 257 +#define R_AARCH64_ABS32 258 +#define R_AARCH64_ABS16 259 +#define R_AARCH64_PREL64 260 +#define R_AARCH64_PREL32 261 +#define R_AARCH64_PREL16 262 +#define R_AARCH64_MOVW_UABS_G0 263 +#define R_AARCH64_MOVW_UABS_G0_NC 264 +#define R_AARCH64_MOVW_UABS_G1 265 +#define R_AARCH64_MOVW_UABS_G1_NC 266 +#define R_AARCH64_MOVW_UABS_G2 267 +#define R_AARCH64_MOVW_UABS_G2_NC 268 +#define R_AARCH64_MOVW_UABS_G3 269 +#define R_AARCH64_MOVW_SABS_G0 270 +#define R_AARCH64_MOVW_SABS_G1 271 +#define R_AARCH64_MOVW_SABS_G2 272 +#define R_AARCH64_LD_PREL_LO19 273 +#define R_AARCH64_ADR_PREL_LO21 274 +#define R_AARCH64_ADR_PREL_PG_HI21 275 +#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 +#define R_AARCH64_ADD_ABS_LO12_NC 277 +#define R_AARCH64_LDST8_ABS_LO12_NC 278 +#define R_AARCH64_TSTBR14 279 +#define R_AARCH64_CONDBR19 280 +#define R_AARCH64_JUMP26 282 +#define R_AARCH64_CALL26 283 +#define R_AARCH64_LDST16_ABS_LO12_NC 284 +#define R_AARCH64_LDST32_ABS_LO12_NC 285 +#define R_AARCH64_LDST64_ABS_LO12_NC 286 +#define R_AARCH64_MOVW_PREL_G0 287 +#define R_AARCH64_MOVW_PREL_G0_NC 288 +#define R_AARCH64_MOVW_PREL_G1 289 +#define R_AARCH64_MOVW_PREL_G1_NC 290 +#define R_AARCH64_MOVW_PREL_G2 291 +#define R_AARCH64_MOVW_PREL_G2_NC 292 +#define R_AARCH64_MOVW_PREL_G3 293 +#define R_AARCH64_LDST128_ABS_LO12_NC 299 +#define R_AARCH64_MOVW_GOTOFF_G0 300 +#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 +#define R_AARCH64_MOVW_GOTOFF_G1 302 +#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 +#define R_AARCH64_MOVW_GOTOFF_G2 304 +#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 +#define R_AARCH64_MOVW_GOTOFF_G3 306 +#define R_AARCH64_GOTREL64 307 +#define R_AARCH64_GOTREL32 308 +#define R_AARCH64_GOT_LD_PREL19 309 +#define R_AARCH64_LD64_GOTOFF_LO15 310 +#define R_AARCH64_ADR_GOT_PAGE 311 +#define R_AARCH64_LD64_GOT_LO12_NC 312 +#define R_AARCH64_LD64_GOTPAGE_LO15 313 +#define R_AARCH64_TLSGD_ADR_PREL21 512 +#define R_AARCH64_TLSGD_ADR_PAGE21 513 +#define R_AARCH64_TLSGD_ADD_LO12_NC 514 +#define R_AARCH64_TLSGD_MOVW_G1 515 +#define R_AARCH64_TLSGD_MOVW_G0_NC 516 +#define R_AARCH64_TLSLD_ADR_PREL21 517 +#define R_AARCH64_TLSLD_ADR_PAGE21 518 +#define R_AARCH64_TLSLD_ADD_LO12_NC 519 +#define R_AARCH64_TLSLD_MOVW_G1 520 +#define R_AARCH64_TLSLD_MOVW_G0_NC 521 +#define R_AARCH64_TLSLD_LD_PREL19 522 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 +#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 +#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 +#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 +#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 +#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 +#define R_AARCH64_TLSDESC_LD_PREL19 560 +#define R_AARCH64_TLSDESC_ADR_PREL21 561 +#define R_AARCH64_TLSDESC_ADR_PAGE21 562 +#define R_AARCH64_TLSDESC_LD64_LO12 563 +#define R_AARCH64_TLSDESC_ADD_LO12 564 +#define R_AARCH64_TLSDESC_OFF_G1 565 +#define R_AARCH64_TLSDESC_OFF_G0_NC 566 +#define R_AARCH64_TLSDESC_LDR 567 +#define R_AARCH64_TLSDESC_ADD 568 +#define R_AARCH64_TLSDESC_CALL 569 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 +#define R_AARCH64_COPY 1024 +#define R_AARCH64_GLOB_DAT 1025 +#define R_AARCH64_JUMP_SLOT 1026 +#define R_AARCH64_RELATIVE 1027 +#define R_AARCH64_TLS_DTPMOD 1028 +#define R_AARCH64_TLS_DTPMOD64 1028 +#define R_AARCH64_TLS_DTPREL 1029 +#define R_AARCH64_TLS_DTPREL64 1029 +#define R_AARCH64_TLS_TPREL 1030 +#define R_AARCH64_TLS_TPREL64 1030 +#define R_AARCH64_TLSDESC 1031 + + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_TLS_DESC 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_TLS_DTPMOD32 17 +#define R_ARM_TLS_DTPOFF32 18 +#define R_ARM_TLS_TPOFF32 19 +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 +#define R_ARM_THM_JUMP19 51 +#define R_ARM_THM_JUMP6 52 +#define R_ARM_THM_ALU_PREL_11_0 53 +#define R_ARM_THM_PC12 54 +#define R_ARM_ABS32_NOI 55 +#define R_ARM_REL32_NOI 56 +#define R_ARM_ALU_PC_G0_NC 57 +#define R_ARM_ALU_PC_G0 58 +#define R_ARM_ALU_PC_G1_NC 59 +#define R_ARM_ALU_PC_G1 60 +#define R_ARM_ALU_PC_G2 61 +#define R_ARM_LDR_PC_G1 62 +#define R_ARM_LDR_PC_G2 63 +#define R_ARM_LDRS_PC_G0 64 +#define R_ARM_LDRS_PC_G1 65 +#define R_ARM_LDRS_PC_G2 66 +#define R_ARM_LDC_PC_G0 67 +#define R_ARM_LDC_PC_G1 68 +#define R_ARM_LDC_PC_G2 69 +#define R_ARM_ALU_SB_G0_NC 70 +#define R_ARM_ALU_SB_G0 71 +#define R_ARM_ALU_SB_G1_NC 72 +#define R_ARM_ALU_SB_G1 73 +#define R_ARM_ALU_SB_G2 74 +#define R_ARM_LDR_SB_G0 75 +#define R_ARM_LDR_SB_G1 76 +#define R_ARM_LDR_SB_G2 77 +#define R_ARM_LDRS_SB_G0 78 +#define R_ARM_LDRS_SB_G1 79 +#define R_ARM_LDRS_SB_G2 80 +#define R_ARM_LDC_SB_G0 81 +#define R_ARM_LDC_SB_G1 82 +#define R_ARM_LDC_SB_G2 83 +#define R_ARM_MOVW_BREL_NC 84 +#define R_ARM_MOVT_BREL 85 +#define R_ARM_MOVW_BREL 86 +#define R_ARM_THM_MOVW_BREL_NC 87 +#define R_ARM_THM_MOVT_BREL 88 +#define R_ARM_THM_MOVW_BREL 89 +#define R_ARM_TLS_GOTDESC 90 +#define R_ARM_TLS_CALL 91 +#define R_ARM_TLS_DESCSEQ 92 +#define R_ARM_THM_TLS_CALL 93 +#define R_ARM_PLT32_ABS 94 +#define R_ARM_GOT_ABS 95 +#define R_ARM_GOT_PREL 96 +#define R_ARM_GOT_BREL12 97 +#define R_ARM_GOTOFF12 98 +#define R_ARM_GOTRELAX 99 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 +#define R_ARM_THM_PC9 103 +#define R_ARM_TLS_GD32 104 + +#define R_ARM_TLS_LDM32 105 + +#define R_ARM_TLS_LDO32 106 + +#define R_ARM_TLS_IE32 107 + +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 +#define R_ARM_ME_TOO 128 +#define R_ARM_THM_TLS_DESCSEQ 129 +#define R_ARM_THM_TLS_DESCSEQ16 129 +#define R_ARM_THM_TLS_DESCSEQ32 130 +#define R_ARM_THM_GOT_BREL12 131 +#define R_ARM_IRELATIVE 160 +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS22 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_ARM_NUM 256 + + + + +#define EF_IA_64_MASKOS 0x0000000f +#define EF_IA_64_ABI64 0x00000010 +#define EF_IA_64_ARCH 0xff000000 + + +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) +#define PT_IA_64_UNWIND (PT_LOPROC + 1) +#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) +#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) +#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) + + +#define PF_IA_64_NORECOV 0x80000000 + + +#define SHT_IA_64_EXT (SHT_LOPROC + 0) +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) + + +#define SHF_IA_64_SHORT 0x10000000 +#define SHF_IA_64_NORECOV 0x20000000 + + +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + + +#define R_IA64_NONE 0x00 +#define R_IA64_IMM14 0x21 +#define R_IA64_IMM22 0x22 +#define R_IA64_IMM64 0x23 +#define R_IA64_DIR32MSB 0x24 +#define R_IA64_DIR32LSB 0x25 +#define R_IA64_DIR64MSB 0x26 +#define R_IA64_DIR64LSB 0x27 +#define R_IA64_GPREL22 0x2a +#define R_IA64_GPREL64I 0x2b +#define R_IA64_GPREL32MSB 0x2c +#define R_IA64_GPREL32LSB 0x2d +#define R_IA64_GPREL64MSB 0x2e +#define R_IA64_GPREL64LSB 0x2f +#define R_IA64_LTOFF22 0x32 +#define R_IA64_LTOFF64I 0x33 +#define R_IA64_PLTOFF22 0x3a +#define R_IA64_PLTOFF64I 0x3b +#define R_IA64_PLTOFF64MSB 0x3e +#define R_IA64_PLTOFF64LSB 0x3f +#define R_IA64_FPTR64I 0x43 +#define R_IA64_FPTR32MSB 0x44 +#define R_IA64_FPTR32LSB 0x45 +#define R_IA64_FPTR64MSB 0x46 +#define R_IA64_FPTR64LSB 0x47 +#define R_IA64_PCREL60B 0x48 +#define R_IA64_PCREL21B 0x49 +#define R_IA64_PCREL21M 0x4a +#define R_IA64_PCREL21F 0x4b +#define R_IA64_PCREL32MSB 0x4c +#define R_IA64_PCREL32LSB 0x4d +#define R_IA64_PCREL64MSB 0x4e +#define R_IA64_PCREL64LSB 0x4f +#define R_IA64_LTOFF_FPTR22 0x52 +#define R_IA64_LTOFF_FPTR64I 0x53 +#define R_IA64_LTOFF_FPTR32MSB 0x54 +#define R_IA64_LTOFF_FPTR32LSB 0x55 +#define R_IA64_LTOFF_FPTR64MSB 0x56 +#define R_IA64_LTOFF_FPTR64LSB 0x57 +#define R_IA64_SEGREL32MSB 0x5c +#define R_IA64_SEGREL32LSB 0x5d +#define R_IA64_SEGREL64MSB 0x5e +#define R_IA64_SEGREL64LSB 0x5f +#define R_IA64_SECREL32MSB 0x64 +#define R_IA64_SECREL32LSB 0x65 +#define R_IA64_SECREL64MSB 0x66 +#define R_IA64_SECREL64LSB 0x67 +#define R_IA64_REL32MSB 0x6c +#define R_IA64_REL32LSB 0x6d +#define R_IA64_REL64MSB 0x6e +#define R_IA64_REL64LSB 0x6f +#define R_IA64_LTV32MSB 0x74 +#define R_IA64_LTV32LSB 0x75 +#define R_IA64_LTV64MSB 0x76 +#define R_IA64_LTV64LSB 0x77 +#define R_IA64_PCREL21BI 0x79 +#define R_IA64_PCREL22 0x7a +#define R_IA64_PCREL64I 0x7b +#define R_IA64_IPLTMSB 0x80 +#define R_IA64_IPLTLSB 0x81 +#define R_IA64_COPY 0x84 +#define R_IA64_SUB 0x85 +#define R_IA64_LTOFF22X 0x86 +#define R_IA64_LDXMOV 0x87 +#define R_IA64_TPREL14 0x91 +#define R_IA64_TPREL22 0x92 +#define R_IA64_TPREL64I 0x93 +#define R_IA64_TPREL64MSB 0x96 +#define R_IA64_TPREL64LSB 0x97 +#define R_IA64_LTOFF_TPREL22 0x9a +#define R_IA64_DTPMOD64MSB 0xa6 +#define R_IA64_DTPMOD64LSB 0xa7 +#define R_IA64_LTOFF_DTPMOD22 0xaa +#define R_IA64_DTPREL14 0xb1 +#define R_IA64_DTPREL22 0xb2 +#define R_IA64_DTPREL64I 0xb3 +#define R_IA64_DTPREL32MSB 0xb4 +#define R_IA64_DTPREL32LSB 0xb5 +#define R_IA64_DTPREL64MSB 0xb6 +#define R_IA64_DTPREL64LSB 0xb7 +#define R_IA64_LTOFF_DTPREL22 0xba + + +#define EF_SH_MACH_MASK 0x1f +#define EF_SH_UNKNOWN 0x0 +#define EF_SH1 0x1 +#define EF_SH2 0x2 +#define EF_SH3 0x3 +#define EF_SH_DSP 0x4 +#define EF_SH3_DSP 0x5 +#define EF_SH4AL_DSP 0x6 +#define EF_SH3E 0x8 +#define EF_SH4 0x9 +#define EF_SH2E 0xb +#define EF_SH4A 0xc +#define EF_SH2A 0xd +#define EF_SH4_NOFPU 0x10 +#define EF_SH4A_NOFPU 0x11 +#define EF_SH4_NOMMU_NOFPU 0x12 +#define EF_SH2A_NOFPU 0x13 +#define EF_SH3_NOMMU 0x14 +#define EF_SH2A_SH4_NOFPU 0x15 +#define EF_SH2A_SH3_NOFPU 0x16 +#define EF_SH2A_SH4 0x17 +#define EF_SH2A_SH3E 0x18 + +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_TLS_GD_32 144 +#define R_SH_TLS_LD_32 145 +#define R_SH_TLS_LDO_32 146 +#define R_SH_TLS_IE_32 147 +#define R_SH_TLS_LE_32 148 +#define R_SH_TLS_DTPMOD32 149 +#define R_SH_TLS_DTPOFF32 150 +#define R_SH_TLS_TPOFF32 151 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +#define R_SH_GOT20 201 +#define R_SH_GOTOFF20 202 +#define R_SH_GOTFUNCDESC 203 +#define R_SH_GOTFUNCDEST20 204 +#define R_SH_GOTOFFFUNCDESC 205 +#define R_SH_GOTOFFFUNCDEST20 206 +#define R_SH_FUNCDESC 207 +#define R_SH_FUNCDESC_VALUE 208 + +#define R_SH_NUM 256 + + + +#define R_390_NONE 0 +#define R_390_8 1 +#define R_390_12 2 +#define R_390_16 3 +#define R_390_32 4 +#define R_390_PC32 5 +#define R_390_GOT12 6 +#define R_390_GOT32 7 +#define R_390_PLT32 8 +#define R_390_COPY 9 +#define R_390_GLOB_DAT 10 +#define R_390_JMP_SLOT 11 +#define R_390_RELATIVE 12 +#define R_390_GOTOFF32 13 +#define R_390_GOTPC 14 +#define R_390_GOT16 15 +#define R_390_PC16 16 +#define R_390_PC16DBL 17 +#define R_390_PLT16DBL 18 +#define R_390_PC32DBL 19 +#define R_390_PLT32DBL 20 +#define R_390_GOTPCDBL 21 +#define R_390_64 22 +#define R_390_PC64 23 +#define R_390_GOT64 24 +#define R_390_PLT64 25 +#define R_390_GOTENT 26 +#define R_390_GOTOFF16 27 +#define R_390_GOTOFF64 28 +#define R_390_GOTPLT12 29 +#define R_390_GOTPLT16 30 +#define R_390_GOTPLT32 31 +#define R_390_GOTPLT64 32 +#define R_390_GOTPLTENT 33 +#define R_390_PLTOFF16 34 +#define R_390_PLTOFF32 35 +#define R_390_PLTOFF64 36 +#define R_390_TLS_LOAD 37 +#define R_390_TLS_GDCALL 38 + +#define R_390_TLS_LDCALL 39 + +#define R_390_TLS_GD32 40 + +#define R_390_TLS_GD64 41 + +#define R_390_TLS_GOTIE12 42 + +#define R_390_TLS_GOTIE32 43 + +#define R_390_TLS_GOTIE64 44 + +#define R_390_TLS_LDM32 45 + +#define R_390_TLS_LDM64 46 + +#define R_390_TLS_IE32 47 + +#define R_390_TLS_IE64 48 + +#define R_390_TLS_IEENT 49 + +#define R_390_TLS_LE32 50 + +#define R_390_TLS_LE64 51 + +#define R_390_TLS_LDO32 52 + +#define R_390_TLS_LDO64 53 + +#define R_390_TLS_DTPMOD 54 +#define R_390_TLS_DTPOFF 55 +#define R_390_TLS_TPOFF 56 + +#define R_390_20 57 +#define R_390_GOT20 58 +#define R_390_GOTPLT20 59 +#define R_390_TLS_GOTIE20 60 + + +#define R_390_NUM 61 + + + +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +#define R_CRIS_NUM 20 + + + +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 + +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 +#define R_X86_64_DTPMOD64 16 +#define R_X86_64_DTPOFF64 17 +#define R_X86_64_TPOFF64 18 +#define R_X86_64_TLSGD 19 + +#define R_X86_64_TLSLD 20 + +#define R_X86_64_DTPOFF32 21 +#define R_X86_64_GOTTPOFF 22 + +#define R_X86_64_TPOFF32 23 +#define R_X86_64_PC64 24 +#define R_X86_64_GOTOFF64 25 +#define R_X86_64_GOTPC32 26 +#define R_X86_64_GOT64 27 +#define R_X86_64_GOTPCREL64 28 +#define R_X86_64_GOTPC64 29 +#define R_X86_64_GOTPLT64 30 +#define R_X86_64_PLTOFF64 31 +#define R_X86_64_SIZE32 32 +#define R_X86_64_SIZE64 33 + +#define R_X86_64_GOTPC32_TLSDESC 34 +#define R_X86_64_TLSDESC_CALL 35 + +#define R_X86_64_TLSDESC 36 +#define R_X86_64_IRELATIVE 37 +#define R_X86_64_RELATIVE64 38 +#define R_X86_64_GOTPCRELX 41 +#define R_X86_64_REX_GOTPCRELX 42 +#define R_X86_64_NUM 43 + + + +#define R_MN10300_NONE 0 +#define R_MN10300_32 1 +#define R_MN10300_16 2 +#define R_MN10300_8 3 +#define R_MN10300_PCREL32 4 +#define R_MN10300_PCREL16 5 +#define R_MN10300_PCREL8 6 +#define R_MN10300_GNU_VTINHERIT 7 +#define R_MN10300_GNU_VTENTRY 8 +#define R_MN10300_24 9 +#define R_MN10300_GOTPC32 10 +#define R_MN10300_GOTPC16 11 +#define R_MN10300_GOTOFF32 12 +#define R_MN10300_GOTOFF24 13 +#define R_MN10300_GOTOFF16 14 +#define R_MN10300_PLT32 15 +#define R_MN10300_PLT16 16 +#define R_MN10300_GOT32 17 +#define R_MN10300_GOT24 18 +#define R_MN10300_GOT16 19 +#define R_MN10300_COPY 20 +#define R_MN10300_GLOB_DAT 21 +#define R_MN10300_JMP_SLOT 22 +#define R_MN10300_RELATIVE 23 + +#define R_MN10300_NUM 24 + + + +#define R_M32R_NONE 0 +#define R_M32R_16 1 +#define R_M32R_32 2 +#define R_M32R_24 3 +#define R_M32R_10_PCREL 4 +#define R_M32R_18_PCREL 5 +#define R_M32R_26_PCREL 6 +#define R_M32R_HI16_ULO 7 +#define R_M32R_HI16_SLO 8 +#define R_M32R_LO16 9 +#define R_M32R_SDA16 10 +#define R_M32R_GNU_VTINHERIT 11 +#define R_M32R_GNU_VTENTRY 12 + +#define R_M32R_16_RELA 33 +#define R_M32R_32_RELA 34 +#define R_M32R_24_RELA 35 +#define R_M32R_10_PCREL_RELA 36 +#define R_M32R_18_PCREL_RELA 37 +#define R_M32R_26_PCREL_RELA 38 +#define R_M32R_HI16_ULO_RELA 39 +#define R_M32R_HI16_SLO_RELA 40 +#define R_M32R_LO16_RELA 41 +#define R_M32R_SDA16_RELA 42 +#define R_M32R_RELA_GNU_VTINHERIT 43 +#define R_M32R_RELA_GNU_VTENTRY 44 +#define R_M32R_REL32 45 + +#define R_M32R_GOT24 48 +#define R_M32R_26_PLTREL 49 +#define R_M32R_COPY 50 +#define R_M32R_GLOB_DAT 51 +#define R_M32R_JMP_SLOT 52 +#define R_M32R_RELATIVE 53 +#define R_M32R_GOTOFF 54 +#define R_M32R_GOTPC24 55 +#define R_M32R_GOT16_HI_ULO 56 + +#define R_M32R_GOT16_HI_SLO 57 + +#define R_M32R_GOT16_LO 58 +#define R_M32R_GOTPC_HI_ULO 59 + +#define R_M32R_GOTPC_HI_SLO 60 + +#define R_M32R_GOTPC_LO 61 + +#define R_M32R_GOTOFF_HI_ULO 62 + +#define R_M32R_GOTOFF_HI_SLO 63 + +#define R_M32R_GOTOFF_LO 64 +#define R_M32R_NUM 256 + +#define R_MICROBLAZE_NONE 0 +#define R_MICROBLAZE_32 1 +#define R_MICROBLAZE_32_PCREL 2 +#define R_MICROBLAZE_64_PCREL 3 +#define R_MICROBLAZE_32_PCREL_LO 4 +#define R_MICROBLAZE_64 5 +#define R_MICROBLAZE_32_LO 6 +#define R_MICROBLAZE_SRO32 7 +#define R_MICROBLAZE_SRW32 8 +#define R_MICROBLAZE_64_NONE 9 +#define R_MICROBLAZE_32_SYM_OP_SYM 10 +#define R_MICROBLAZE_GNU_VTINHERIT 11 +#define R_MICROBLAZE_GNU_VTENTRY 12 +#define R_MICROBLAZE_GOTPC_64 13 +#define R_MICROBLAZE_GOT_64 14 +#define R_MICROBLAZE_PLT_64 15 +#define R_MICROBLAZE_REL 16 +#define R_MICROBLAZE_JUMP_SLOT 17 +#define R_MICROBLAZE_GLOB_DAT 18 +#define R_MICROBLAZE_GOTOFF_64 19 +#define R_MICROBLAZE_GOTOFF_32 20 +#define R_MICROBLAZE_COPY 21 +#define R_MICROBLAZE_TLS 22 +#define R_MICROBLAZE_TLSGD 23 +#define R_MICROBLAZE_TLSLD 24 +#define R_MICROBLAZE_TLSDTPMOD32 25 +#define R_MICROBLAZE_TLSDTPREL32 26 +#define R_MICROBLAZE_TLSDTPREL64 27 +#define R_MICROBLAZE_TLSGOTTPREL32 28 +#define R_MICROBLAZE_TLSTPREL32 29 + +#define DT_NIOS2_GP 0x70000002 + +#define R_NIOS2_NONE 0 +#define R_NIOS2_S16 1 +#define R_NIOS2_U16 2 +#define R_NIOS2_PCREL16 3 +#define R_NIOS2_CALL26 4 +#define R_NIOS2_IMM5 5 +#define R_NIOS2_CACHE_OPX 6 +#define R_NIOS2_IMM6 7 +#define R_NIOS2_IMM8 8 +#define R_NIOS2_HI16 9 +#define R_NIOS2_LO16 10 +#define R_NIOS2_HIADJ16 11 +#define R_NIOS2_BFD_RELOC_32 12 +#define R_NIOS2_BFD_RELOC_16 13 +#define R_NIOS2_BFD_RELOC_8 14 +#define R_NIOS2_GPREL 15 +#define R_NIOS2_GNU_VTINHERIT 16 +#define R_NIOS2_GNU_VTENTRY 17 +#define R_NIOS2_UJMP 18 +#define R_NIOS2_CJMP 19 +#define R_NIOS2_CALLR 20 +#define R_NIOS2_ALIGN 21 +#define R_NIOS2_GOT16 22 +#define R_NIOS2_CALL16 23 +#define R_NIOS2_GOTOFF_LO 24 +#define R_NIOS2_GOTOFF_HA 25 +#define R_NIOS2_PCREL_LO 26 +#define R_NIOS2_PCREL_HA 27 +#define R_NIOS2_TLS_GD16 28 +#define R_NIOS2_TLS_LDM16 29 +#define R_NIOS2_TLS_LDO16 30 +#define R_NIOS2_TLS_IE16 31 +#define R_NIOS2_TLS_LE16 32 +#define R_NIOS2_TLS_DTPMOD 33 +#define R_NIOS2_TLS_DTPREL 34 +#define R_NIOS2_TLS_TPREL 35 +#define R_NIOS2_COPY 36 +#define R_NIOS2_GLOB_DAT 37 +#define R_NIOS2_JUMP_SLOT 38 +#define R_NIOS2_RELATIVE 39 +#define R_NIOS2_GOTOFF 40 +#define R_NIOS2_CALL26_NOAT 41 +#define R_NIOS2_GOT_LO 42 +#define R_NIOS2_GOT_HA 43 +#define R_NIOS2_CALL_LO 44 +#define R_NIOS2_CALL_HA 45 + +#define R_OR1K_NONE 0 +#define R_OR1K_32 1 +#define R_OR1K_16 2 +#define R_OR1K_8 3 +#define R_OR1K_LO_16_IN_INSN 4 +#define R_OR1K_HI_16_IN_INSN 5 +#define R_OR1K_INSN_REL_26 6 +#define R_OR1K_GNU_VTENTRY 7 +#define R_OR1K_GNU_VTINHERIT 8 +#define R_OR1K_32_PCREL 9 +#define R_OR1K_16_PCREL 10 +#define R_OR1K_8_PCREL 11 +#define R_OR1K_GOTPC_HI16 12 +#define R_OR1K_GOTPC_LO16 13 +#define R_OR1K_GOT16 14 +#define R_OR1K_PLT26 15 +#define R_OR1K_GOTOFF_HI16 16 +#define R_OR1K_GOTOFF_LO16 17 +#define R_OR1K_COPY 18 +#define R_OR1K_GLOB_DAT 19 +#define R_OR1K_JMP_SLOT 20 +#define R_OR1K_RELATIVE 21 +#define R_OR1K_TLS_GD_HI16 22 +#define R_OR1K_TLS_GD_LO16 23 +#define R_OR1K_TLS_LDM_HI16 24 +#define R_OR1K_TLS_LDM_LO16 25 +#define R_OR1K_TLS_LDO_HI16 26 +#define R_OR1K_TLS_LDO_LO16 27 +#define R_OR1K_TLS_IE_HI16 28 +#define R_OR1K_TLS_IE_LO16 29 +#define R_OR1K_TLS_LE_HI16 30 +#define R_OR1K_TLS_LE_LO16 31 +#define R_OR1K_TLS_TPOFF 32 +#define R_OR1K_TLS_DTPOFF 33 +#define R_OR1K_TLS_DTPMOD 34 + +#define R_BPF_NONE 0 +#define R_BPF_MAP_FD 1 + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/tools/gbafix/gbafix.c b/tools/gbafix/gbafix.c index 81c8c04c0..b4ad15a88 100644 --- a/tools/gbafix/gbafix.c +++ b/tools/gbafix/gbafix.c @@ -1,45 +1,45 @@ /* - "$Id: gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $" + "$Id: gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $" - DevkitPro GBA ROM fix utility + DevkitPro GBA ROM fix utility - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. - This library 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 - Library General Public License for more details. + This library 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 + Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. - Please report all bugs and problems through the bug tracker at - "http://sourceforge.net/tracker/?group_id=114505&atid=668551". + Please report all bugs and problems through the bug tracker at + "http://sourceforge.net/tracker/?group_id=114505&atid=668551". - "$Header: /lvm/shared/ds/ds/cvs/devkitpro-cvsbackup/tools/gba/gbatools/gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $" + "$Header: /lvm/shared/ds/ds/cvs/devkitpro-cvsbackup/tools/gba/gbatools/gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $" */ //--------------------------------------------------------------------------------- // gbafix.c //--------------------------------------------------------------------------------- /* - Gameboy Advance ROM fixer (by Dark Fader / BlackThunder / WinterMute / Diegoisawesome) - Validates header of GBA roms. + Gameboy Advance ROM fixer (by Dark Fader / BlackThunder / WinterMute / Diegoisawesome) + Validates header of GBA roms. - History - ------- - v1.06 - added output silencing, (Diegoisawesome) - v1.05 - added debug offset argument, (Diegoisawesome) - v1.04 - converted to plain C, (WinterMute) - v1.03 - header.fixed, header.device_type - v1.02 - redefined the options (rgbfix style), checksum=0 - v1.01 - fix in parameters - v1.00 - logo, complement + History + ------- + v1.06 - added output silencing, (Diegoisawesome) + v1.05 - added debug offset argument, (Diegoisawesome) + v1.04 - converted to plain C, (WinterMute) + v1.03 - header.fixed, header.device_type + v1.02 - redefined the options (rgbfix style), checksum=0 + v1.01 - fix in parameters + v1.00 - logo, complement */ #pragma pack(1) @@ -48,26 +48,27 @@ #include #include #include +#include "elf.h" -#define VER "1.06" -#define ARGV argv[arg] -#define VALUE (ARGV+2) -#define NUMBER strtoul(VALUE, NULL, 0) +#define VER "1.06" +#define ARGV argv[arg] +#define VALUE (ARGV+2) +#define NUMBER strtoul(VALUE, NULL, 0) typedef struct { - uint32_t start_code; // B instruction - uint8_t logo[0xA0-0x04]; // logo data - uint8_t title[0xC]; // game title name - uint32_t game_code; // - uint16_t maker_code; // - uint8_t fixed; // 0x96 - uint8_t unit_code; // 0x00 - uint8_t device_type; // 0x00 - uint8_t unused[7]; // - uint8_t game_version; // 0x00 - uint8_t complement; // 800000A0..800000BC - uint16_t checksum; // 0x0000 + uint32_t start_code; // B instruction + uint8_t logo[0xA0-0x04]; // logo data + uint8_t title[0xC]; // game title name + uint32_t game_code; // + uint16_t maker_code; // + uint8_t fixed; // 0x96 + uint8_t unit_code; // 0x00 + uint8_t device_type; // 0x00 + uint8_t unused[7]; // + uint8_t game_version; // 0x00 + uint8_t complement; // 800000A0..800000BC + uint16_t checksum; // 0x0000 } Header; @@ -77,55 +78,55 @@ unsigned short checksum_without_header = 0; const Header good_header = { - // start_code - 0xEA00002E, - // logo - { 0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84,0x82,0x0A,0x84,0xE4,0x09,0xAD, - 0x11,0x24,0x8B,0x98,0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09,0xCE,0x20, - 0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC,0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF, - 0x85,0xF4,0xDF,0x94,0xCE,0x4B,0x09,0xC1,0x94,0x56,0x8A,0xC0,0x13,0x72,0xA7,0xFC, - 0x9F,0x84,0x4D,0x73,0xA3,0xCA,0x9A,0x61,0x58,0x97,0xA3,0x27,0xFC,0x03,0x98,0x76, - 0x23,0x1D,0xC7,0x61,0x03,0x04,0xAE,0x56,0xBF,0x38,0x84,0x00,0x40,0xA7,0x0E,0xFD, - 0xFF,0x52,0xFE,0x03,0x6F,0x95,0x30,0xF1,0x97,0xFB,0xC0,0x85,0x60,0xD6,0x80,0x25, - 0xA9,0x63,0xBE,0x03,0x01,0x4E,0x38,0xE2,0xF9,0xA2,0x34,0xFF,0xBB,0x3E,0x03,0x44, - 0x78,0x00,0x90,0xCB,0x88,0x11,0x3A,0x94,0x65,0xC0,0x7C,0x63,0x87,0xF0,0x3C,0xAF, - 0xD6,0x25,0xE4,0x8B,0x38,0x0A,0xAC,0x72,0x21,0xD4,0xF8,0x07 } , - // title - { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, - // game code - 0x00000000, - // maker code - 0x3130, - // fixed - 0x96, - // unit_code - 0x00, - // device type - 0x00, - // unused - { 0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, - // game version - 0x00, - // complement - 0x00, - // checksum - 0x0000 + // start_code + 0xEA00002E, + // logo + { 0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84,0x82,0x0A,0x84,0xE4,0x09,0xAD, + 0x11,0x24,0x8B,0x98,0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09,0xCE,0x20, + 0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC,0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF, + 0x85,0xF4,0xDF,0x94,0xCE,0x4B,0x09,0xC1,0x94,0x56,0x8A,0xC0,0x13,0x72,0xA7,0xFC, + 0x9F,0x84,0x4D,0x73,0xA3,0xCA,0x9A,0x61,0x58,0x97,0xA3,0x27,0xFC,0x03,0x98,0x76, + 0x23,0x1D,0xC7,0x61,0x03,0x04,0xAE,0x56,0xBF,0x38,0x84,0x00,0x40,0xA7,0x0E,0xFD, + 0xFF,0x52,0xFE,0x03,0x6F,0x95,0x30,0xF1,0x97,0xFB,0xC0,0x85,0x60,0xD6,0x80,0x25, + 0xA9,0x63,0xBE,0x03,0x01,0x4E,0x38,0xE2,0xF9,0xA2,0x34,0xFF,0xBB,0x3E,0x03,0x44, + 0x78,0x00,0x90,0xCB,0x88,0x11,0x3A,0x94,0x65,0xC0,0x7C,0x63,0x87,0xF0,0x3C,0xAF, + 0xD6,0x25,0xE4,0x8B,0x38,0x0A,0xAC,0x72,0x21,0xD4,0xF8,0x07 } , + // title + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + // game code + 0x00000000, + // maker code + 0x3130, + // fixed + 0x96, + // unit_code + 0x00, + // device type + 0x00, + // unused + { 0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, + // game version + 0x00, + // complement + 0x00, + // checksum + 0x0000 }; //--------------------------------------------------------------------------------- char HeaderComplement() /*--------------------------------------------------------------------------------- - Calculate Header complement check + Calculate Header complement check ---------------------------------------------------------------------------------*/ { - int n; - char c = 0; - char *p = (char *)&header + 0xA0; - for (n=0; n<0xBD-0xA0; n++) - { - c += *p++; - } - return -(0x19+c); + int n; + char c = 0; + char *p = (char *)&header + 0xA0; + for (n=0; n<0xBD-0xA0; n++) + { + c += *p++; + } + return -(0x19+c); } @@ -133,157 +134,176 @@ char HeaderComplement() int main(int argc, char *argv[]) //--------------------------------------------------------------------------------- { - int arg; - char *argfile = 0; - FILE *infile; - int silent = 0; + int arg; + char *argfile = 0; + FILE *infile; + int silent = 0; - int size,bit; + int size,bit; - // show syntax - if (argc <= 1) - { - printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Diegoisawesome \n"); - printf("Syntax: gbafix [-p] [-t[title]] [-c] [-m] [-r] [-d] [--silent]\n"); - printf("\n"); - printf("parameters:\n"); - printf(" -p Pad to next exact power of 2. No minimum size!\n"); - printf(" -t[] Patch title. Stripped filename if none given.\n"); - printf(" -c<game_code> Patch game code (four characters)\n"); - printf(" -m<maker_code> Patch maker code (two characters)\n"); - printf(" -r<version> Patch game version (number)\n"); - printf(" -d<debug> Enable debugging handler and set debug entry point (0 or 1)\n"); - printf(" --silent Silence non-error output\n"); - return -1; - } + // show syntax + if (argc <= 1) + { + printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Diegoisawesome \n"); + printf("Syntax: gbafix <rom.gba> [-p] [-t[title]] [-c<game_code>] [-m<maker_code>] [-r<version>] [-d<debug>] [--silent]\n"); + printf("\n"); + printf("parameters:\n"); + printf(" -p Pad to next exact power of 2. No minimum size!\n"); + printf(" -t[<title>] Patch title. Stripped filename if none given.\n"); + printf(" -c<game_code> Patch game code (four characters)\n"); + printf(" -m<maker_code> Patch maker code (two characters)\n"); + printf(" -r<version> Patch game version (number)\n"); + printf(" -d<debug> Enable debugging handler and set debug entry point (0 or 1)\n"); + printf(" --silent Silence non-error output\n"); + return -1; + } - // get filename - for (arg=1; arg<argc; arg++) - { - if (ARGV[0] != '-') { argfile=ARGV; } - if (strncmp("--silent", &ARGV[0], 7) == 0) { silent = 1; } - } + // get filename + for (arg=1; arg<argc; arg++) + { + if (ARGV[0] != '-') { argfile=ARGV; } + if (strncmp("--silent", &ARGV[0], 7) == 0) { silent = 1; } + } - // check filename - if (!argfile) - { - fprintf(stderr, "Filename needed!\n"); - return -1; - } + // check filename + if (!argfile) + { + fprintf(stderr, "Filename needed!\n"); + return -1; + } - // read file - infile = fopen(argfile, "r+b"); - if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; } - fseek(infile, 0, SEEK_SET); - fread(&header, sizeof(header), 1, infile); + // read file + infile = fopen(argfile, "r+b"); + if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; } + fseek(infile, 0, SEEK_SET); + fread(&header, sizeof(header), 1, infile); - // fix some data - memcpy(header.logo, good_header.logo, sizeof(header.logo)); - memcpy(&header.fixed, &good_header.fixed, sizeof(header.fixed)); - memcpy(&header.device_type, &good_header.device_type, sizeof(header.device_type)); + // elf check + uint32_t sh_offset = 0; + if (memcmp(&header, ELFMAG, 4) == 0) { + Elf32_Ehdr *elfHeader = (Elf32_Ehdr *)&header; + fseek(infile, elfHeader->e_shoff, SEEK_SET); + int i; + for (i = 0; i < elfHeader->e_shnum; i++) { + Elf32_Shdr secHeader; + fread(&secHeader, sizeof(Elf32_Shdr), 1, infile); + if (secHeader.sh_type == SHT_PROGBITS && secHeader.sh_addr == elfHeader->e_entry) { + fseek(infile, secHeader.sh_offset, SEEK_SET); + sh_offset = secHeader.sh_offset; + break; + } + } + if (i == elfHeader->e_shnum) { fprintf(stderr, "Error finding entry point!\n"); return 1; } + fread(&header, sizeof(header), 1, infile); + } - // parse command line - for (arg=1; arg<argc; arg++) - { - if ((ARGV[0] == '-')) - { - switch (ARGV[1]) - { - case 'p': // pad - { - fseek(infile, 0, SEEK_END); - size = ftell(infile); - for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break; - if (size != (1<<bit)) - { - int todo = (1<<(bit+1)) - size; - while (todo--) fputc(0xFF, infile); - } - fseek(infile, 0, SEEK_SET); - break; - } + // fix some data + memcpy(header.logo, good_header.logo, sizeof(header.logo)); + memcpy(&header.fixed, &good_header.fixed, sizeof(header.fixed)); + memcpy(&header.device_type, &good_header.device_type, sizeof(header.device_type)); - case 't': // title - { - char title[256]; - memset(title, 0, sizeof(title)); - if (VALUE[0]) - { - strncpy(title, VALUE, sizeof(header.title)); - } - else - { - // use filename - char s[256], *begin=s, *t; strcpy(s, argfile); - t = strrchr(s, '\\'); if (t) begin = t+1; - t = strrchr(s, '/'); if (t) begin = t+1; - t = strrchr(s, '.'); if (t) *t = 0; - strncpy(title, begin, sizeof(header.title)); - if (!silent) printf("%s\n",begin); - } - memcpy(header.title, title, sizeof(header.title)); // copy - break; - } + // parse command line + for (arg=1; arg<argc; arg++) + { + if ((ARGV[0] == '-')) + { + switch (ARGV[1]) + { + case 'p': // pad + { + fseek(infile, 0, SEEK_END); + size = ftell(infile); + for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break; + if (size != (1<<bit)) + { + int todo = (1<<(bit+1)) - size; + while (todo--) fputc(0xFF, infile); + } + fseek(infile, 0, SEEK_SET); + break; + } - case 'c': // game code - { - //if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } - //header.game_code = NUMBER; - header.game_code = VALUE[0] | VALUE[1]<<8 | VALUE[2]<<16 | VALUE[3]<<24; - break; - } + case 't': // title + { + char title[256]; + memset(title, 0, sizeof(title)); + if (VALUE[0]) + { + strncpy(title, VALUE, sizeof(header.title)); + } + else + { + // use filename + char s[256], *begin=s, *t; strcpy(s, argfile); + t = strrchr(s, '\\'); if (t) begin = t+1; + t = strrchr(s, '/'); if (t) begin = t+1; + t = strrchr(s, '.'); if (t) *t = 0; + strncpy(title, begin, sizeof(header.title)); + if (!silent) printf("%s\n",begin); + } + memcpy(header.title, title, sizeof(header.title)); // copy + break; + } - case 'm': // maker code - { - //if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } - //header.maker_code = (unsigned short)NUMBER; - header.maker_code = VALUE[0] | VALUE[1]<<8; - break; - } + case 'c': // game code + { + //if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } + //header.game_code = NUMBER; + header.game_code = VALUE[0] | VALUE[1]<<8 | VALUE[2]<<16 | VALUE[3]<<24; + break; + } - case 'v': // ignored, compatability with other gbafix - { - break; - } + case 'm': // maker code + { + //if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } + //header.maker_code = (unsigned short)NUMBER; + header.maker_code = VALUE[0] | VALUE[1]<<8; + break; + } - case 'r': // version - { - if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } - header.game_version = (unsigned char)NUMBER; - break; - } + case 'v': // ignored, compatability with other gbafix + { + break; + } - case 'd': // debug - { - if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } - header.logo[0x9C-0x04] = 0xA5; // debug enable - header.device_type = (unsigned char)((NUMBER & 1) << 7); // debug handler entry point - break; - } - case '-': // long arguments - { - if (strncmp("silent", &ARGV[2], 6) == 0) { continue; } - break; - } - default: - { - printf("Invalid option: %s\n", ARGV); - } - } - } - } + case 'r': // version + { + if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } + header.game_version = (unsigned char)NUMBER; + break; + } - // update complement check & total checksum - header.complement = 0; - header.checksum = 0; // must be 0 - header.complement = HeaderComplement(); - //header.checksum = checksum_without_header + HeaderChecksum(); + case 'd': // debug + { + if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; } + header.logo[0x9C-0x04] = 0xA5; // debug enable + header.device_type = (unsigned char)((NUMBER & 1) << 7); // debug handler entry point + break; + } + case '-': // long arguments + { + if (strncmp("silent", &ARGV[2], 6) == 0) { continue; } + break; + } + default: + { + printf("Invalid option: %s\n", ARGV); + } + } + } + } - fseek(infile, 0, SEEK_SET); - fwrite(&header, sizeof(header), 1, infile); - fclose(infile); + // update complement check & total checksum + header.complement = 0; + header.checksum = 0; // must be 0 + header.complement = HeaderComplement(); + //header.checksum = checksum_without_header + HeaderChecksum(); - if (!silent) printf("ROM fixed!\n"); + fseek(infile, sh_offset, SEEK_SET); + fwrite(&header, sizeof(header), 1, infile); + fclose(infile); - return 0; + if (!silent) printf("ROM fixed!\n"); + + return 0; } From b839c213073f99d73d03bb28f0fd350e13afba09 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Wed, 26 Jun 2019 16:23:00 -0400 Subject: [PATCH 04/19] Fix/suppress warnings when building with gcc-8 --- Makefile | 2 +- include/gba/defines.h | 4 ---- src/battle_factory.c | 2 +- src/battle_factory_screen.c | 6 +++--- src/battle_pike.c | 10 +++++----- src/battle_tent.c | 2 +- src/battle_transition.c | 8 ++++---- src/berry_blender.c | 8 ++++---- src/bg.c | 6 +++--- src/egg_hatch.c | 2 +- src/field_camera.c | 10 +++++----- src/field_effect.c | 2 +- src/field_weather.c | 2 +- src/fldeff_cut.c | 10 +++++----- src/load_save.c | 8 ++++---- src/main.c | 9 ++++++++- src/main_menu.c | 2 +- src/menu_helpers.c | 2 +- src/mirage_tower.c | 2 +- src/multiboot.c | 2 +- src/overworld.c | 12 ++++++------ src/party_menu.c | 4 ++-- src/pokedex_area_screen.c | 10 +++++----- src/pokemon_animation.c | 6 +++--- src/pokemon_storage_system.c | 2 +- src/random.c | 4 ++-- src/record_mixing.c | 30 +++++++++++++++--------------- src/recorded_battle.c | 4 ++-- src/reset_save_heap.c | 2 +- src/rom_8034C54.c | 6 +++--- src/roulette_util.c | 4 ++-- src/rtc.c | 8 ++++---- src/script.c | 12 ++++++------ src/slot_machine.c | 2 +- src/sound.c | 10 +++++----- src/sprite.c | 8 ++++---- src/starter_choose.c | 2 +- 37 files changed, 114 insertions(+), 111 deletions(-) diff --git a/Makefile b/Makefile index cffbcf87f..b23b278be 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ ROM := pokeemerald.gba OBJ_DIR := build/emerald else CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations +override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations -Wno-pointer-to-int-cast ROM := pokeemerald_modern.gba OBJ_DIR := build/modern endif diff --git a/include/gba/defines.h b/include/gba/defines.h index b95946b15..9bd695aaa 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -7,11 +7,7 @@ #define FALSE 0 #define BSS_DATA __attribute__((section(".bss"))) -#if MODERN -#define IWRAM_DATA -#else #define IWRAM_DATA __attribute__((section("iwram_data"))) -#endif #define EWRAM_DATA __attribute__((section("ewram_data"))) #if MODERN diff --git a/src/battle_factory.c b/src/battle_factory.c index 1a150db1e..6c249bccc 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -16,7 +16,7 @@ #include "constants/moves.h" // IWRAM bss -static IWRAM_DATA bool8 sPerformedRentalSwap; +static bool8 sPerformedRentalSwap; // This file's functions. static void InitFactoryChallenge(void); diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 280b65dc8..f56442432 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -227,9 +227,9 @@ static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL; static EWRAM_DATA u8 *sSwapMonCardBgTilemapBuffer = NULL; // IWRAM bss -static IWRAM_DATA struct FactorySelectMonsStruct *sFactorySelectScreen; -static IWRAM_DATA void (*sSwap_CurrentTableFunc)(u8 taskId); -static IWRAM_DATA struct FactorySwapMonsStruct *sFactorySwapScreen; +static struct FactorySelectMonsStruct *sFactorySelectScreen; +static void (*sSwap_CurrentTableFunc)(u8 taskId); +static struct FactorySwapMonsStruct *sFactorySwapScreen; // IWRAM common u8 (*gUnknown_030062E8)(void); diff --git a/src/battle_pike.c b/src/battle_pike.c index 7fdb0a07c..8846e2d1a 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -53,11 +53,11 @@ struct PikeWildMon }; // IWRAM bss -static IWRAM_DATA u8 sRoomType; -static IWRAM_DATA u8 sStatusMon; -static IWRAM_DATA bool8 sUnknown_0300128E; -static IWRAM_DATA u32 sStatusFlags; -static IWRAM_DATA u8 sNpcId; +static u8 sRoomType; +static u8 sStatusMon; +static bool8 sUnknown_0300128E; +static u32 sStatusFlags; +static u8 sNpcId; // This file's functions. static void SetRoomType(void); diff --git a/src/battle_tent.c b/src/battle_tent.c index 85194417f..34e3e9628 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -44,7 +44,7 @@ static void sub_81BA040(void); static void sub_81B9EC0(void); // IWRAM bss -static IWRAM_DATA u16 sRandMonSetId; +static u16 sRandMonSetId; // const rom data void static (*const gUnknown_086160B4[])(void) = diff --git a/src/battle_transition.c b/src/battle_transition.c index 7edb1bd93..3e86fcf51 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -262,10 +262,10 @@ static bool8 sub_814842C(struct Sprite *sprite); static bool8 sub_8148458(struct Sprite *sprite); // iwram bss vars -IWRAM_DATA static s16 sUnusedRectangularSpiralVar; -IWRAM_DATA static u8 sTestingTransitionId; -IWRAM_DATA static u8 sTestingTransitionState; -IWRAM_DATA static struct StructRectangularSpiral sRectangularSpiralTransition[4]; +static s16 sUnusedRectangularSpiralVar; +static u8 sTestingTransitionId; +static u8 sTestingTransitionState; +static struct StructRectangularSpiral sRectangularSpiralTransition[4]; // ewram vars EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL; diff --git a/src/berry_blender.c b/src/berry_blender.c index d6a7879f4..03764b2f8 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -194,10 +194,10 @@ EWRAM_DATA static s32 sUnknown_020322BC[5] = {0}; EWRAM_DATA static u32 sUnknown_020322D0 = 0; // IWRAM bss -IWRAM_DATA static s16 sUnknown_03000DE8[8]; -IWRAM_DATA static s16 sUnknown_03000DF8[6]; -IWRAM_DATA static s16 sUnknown_03000E04; -IWRAM_DATA static s16 sUnknown_03000E06; +static s16 sUnknown_03000DE8[8]; +static s16 sUnknown_03000DF8[6]; +static s16 sUnknown_03000E04; +static s16 sUnknown_03000E06; // IWRAM common u8 gInGameOpponentsNo; diff --git a/src/bg.c b/src/bg.c index abeb49306..43570f5eb 100644 --- a/src/bg.c +++ b/src/bg.c @@ -37,9 +37,9 @@ struct BgConfig2 s32 bg_y; }; -static IWRAM_DATA struct BgControl sGpuBgConfigs; -static IWRAM_DATA struct BgConfig2 sGpuBgConfigs2[4]; -static IWRAM_DATA u32 sDmaBusyBitfield[4]; +static struct BgControl sGpuBgConfigs; +static struct BgConfig2 sGpuBgConfigs2[4]; +static u32 sDmaBusyBitfield[4]; u32 gUnneededFireRedVariable; diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 605cd0366..835141ef2 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -73,7 +73,7 @@ static void CreateRandomEggShardSprite(void); static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex); // IWRAM bss -static IWRAM_DATA struct EggHatchData *sEggHatchData; +static struct EggHatchData *sEggHatchData; // rom data static const u16 sEggPalette[] = INCBIN_U16("graphics/pokemon/egg/normal.gbapal"); diff --git a/src/field_camera.c b/src/field_camera.c index b976cf2ff..7f294afdb 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -36,11 +36,11 @@ static void DrawMetatile(s32 a, u16 *b, u16 c); static void CameraPanningCB_PanAhead(void); // IWRAM bss vars -static IWRAM_DATA struct FieldCameraOffset sFieldCameraOffset; -static IWRAM_DATA s16 sHorizontalCameraPan; -static IWRAM_DATA s16 sVerticalCameraPan; -static IWRAM_DATA u8 gUnknown_03000E2C; -static IWRAM_DATA void (*sFieldCameraPanningCallback)(void); +static struct FieldCameraOffset sFieldCameraOffset; +static s16 sHorizontalCameraPan; +static s16 sVerticalCameraPan; +static u8 gUnknown_03000E2C; +static void (*sFieldCameraPanningCallback)(void); struct CameraObject gFieldCamera; u16 gTotalCameraPixelOffsetY; diff --git a/src/field_effect.c b/src/field_effect.c index 22bf44f28..7569bdc75 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -232,7 +232,7 @@ static void Fldeff_MoveDeoxysRock_Step(u8 taskId); // Static RAM declarations -static IWRAM_DATA u8 sActiveList[32]; +static u8 sActiveList[32]; // External declarations extern struct CompressedSpritePalette gMonPaletteTable[]; // GF made a mistake and did not extern it as const. diff --git a/src/field_weather.c b/src/field_weather.c index 814e85ef4..024b6631f 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -68,7 +68,7 @@ static u8 None_Finish(void); EWRAM_DATA struct Weather gWeather = {0}; EWRAM_DATA static u8 sFieldEffectPaletteGammaTypes[32] = {0}; -IWRAM_DATA static const u8 *sPaletteGammaTypes; +static const u8 *sPaletteGammaTypes; // The drought weather effect uses a precalculated color lookup table. Presumably this // is because the underlying color shift calculation is slow. diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 68c50cae7..3115ff231 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -59,11 +59,11 @@ static void CutGrassSpriteCallbackEnd(struct Sprite *); static void HandleLongGrassOnHyper(u8, s16, s16); // IWRAM variables -static IWRAM_DATA u8 sCutSquareSide; -static IWRAM_DATA u8 sTileCountFromPlayer_X; -static IWRAM_DATA u8 sTileCountFromPlayer_Y; -static IWRAM_DATA u32 sUnused; -static IWRAM_DATA bool8 sHyperCutTiles[CUT_HYPER_AREA]; +static u8 sCutSquareSide; +static u8 sTileCountFromPlayer_X; +static u8 sTileCountFromPlayer_Y; +static u32 sUnused; +static bool8 sHyperCutTiles[CUT_HYPER_AREA]; // EWRAM variables static EWRAM_DATA u8 *sCutGrassSpriteArrayPtr = NULL; diff --git a/src/load_save.c b/src/load_save.c index 150c557c6..5857f2b46 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -42,10 +42,10 @@ EWRAM_DATA struct LoadedSaveData gLoadedSaveData = {0}; EWRAM_DATA u32 gLastEncryptionKey = 0; // IWRAM common -IWRAM_DATA bool32 gFlashMemoryPresent; -IWRAM_DATA struct SaveBlock1 *gSaveBlock1Ptr; -IWRAM_DATA struct SaveBlock2 *gSaveBlock2Ptr; -IWRAM_DATA struct PokemonStorage *gPokemonStoragePtr; +bool32 gFlashMemoryPresent; +struct SaveBlock1 *gSaveBlock1Ptr; +struct SaveBlock2 *gSaveBlock2Ptr; +struct PokemonStorage *gPokemonStoragePtr; // code void CheckForFlashMemory(void) diff --git a/src/main.c b/src/main.c index d0c9ff7b4..47a957ce0 100644 --- a/src/main.c +++ b/src/main.c @@ -85,7 +85,14 @@ void EnableVCountIntrAtLine150(void); void AgbMain() { - RegisterRamReset(MODERN ? RESET_ALL & ~RESET_IWRAM : RESET_ALL); +#if MODERN + // Modern compilers are liberal with the stack on entry to this function, + // so RegisterRamReset may crash if it resets IWRAM. + RegisterRamReset(RESET_ALL & ~RESET_IWRAM); + DmaFill32(3, 0, IWRAM_START, 0x7E00); +#else + RegisterRamReset(RESET_ALL); +#endif //MODERN *(vu16 *)BG_PLTT = 0x7FFF; InitGpuRegManager(); REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3; diff --git a/src/main_menu.c b/src/main_menu.c index bc509c70d..6a0bd9e2d 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -176,7 +176,7 @@ static EWRAM_DATA u8 gUnknown_02022D04 = 0; static EWRAM_DATA u16 sCurrItemAndOptionMenuCheck = 0; -static IWRAM_DATA u8 sBirchSpeechMainTaskId; +static u8 sBirchSpeechMainTaskId; // Static ROM declarations diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 801e2546b..cb0d621c6 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -27,7 +27,7 @@ EWRAM_DATA static struct YesNoFuncTable gUnknown_0203A138 = {0}; EWRAM_DATA static u8 gUnknown_0203A140 = 0; // IWRAM bss vars -IWRAM_DATA static TaskFunc gUnknown_0300117C; +static TaskFunc gUnknown_0300117C; // const rom data static const struct OamData sOamData_859F4E8 = diff --git a/src/mirage_tower.c b/src/mirage_tower.c index 269f8ea1b..e398c2334 100644 --- a/src/mirage_tower.c +++ b/src/mirage_tower.c @@ -258,7 +258,7 @@ EWRAM_DATA static struct Struct203CF10 *sUnknown_0203CF10 = NULL; EWRAM_DATA static struct BgRegOffsets *sBgShakeOffsets = NULL; EWRAM_DATA struct MirageTowerPulseBlend *sMirageTowerPulseBlend = NULL; -IWRAM_DATA static u16 gUnknown_030012A8[8]; +static u16 gUnknown_030012A8[8]; bool8 IsMirageTowerVisible(void) { diff --git a/src/multiboot.c b/src/multiboot.c index 5cc3ad17e..c7e14392e 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -1,7 +1,7 @@ #include "gba/gba.h" #include "multiboot.h" -IWRAM_DATA static u16 MultiBoot_required_data[MULTIBOOT_NCHILD]; +static u16 MultiBoot_required_data[MULTIBOOT_NCHILD]; static int MultiBootSend(struct MultiBootParam *mp, u16 data); static int MultiBootHandShake(struct MultiBootParam *mp); diff --git a/src/overworld.c b/src/overworld.c index 4356752c1..2097abc53 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -186,15 +186,15 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr static u16 GetCenterScreenMetatileBehavior(void); // IWRAM bss vars -IWRAM_DATA static void *sUnusedOverworldCallback; -IWRAM_DATA static u8 sPlayerTradingStates[4]; +static void *sUnusedOverworldCallback; +static u8 sPlayerTradingStates[4]; // This callback is called with a player's key code. It then returns an // adjusted key code, effectively intercepting the input before anything // can process it. -IWRAM_DATA static u16 (*sPlayerKeyInterceptCallback)(u32); -IWRAM_DATA static bool8 sUnknown_03000E18; -IWRAM_DATA static u8 sRfuKeepAliveTimer; -IWRAM_DATA static u32 sUnusedVar; +static u16 (*sPlayerKeyInterceptCallback)(u32); +static bool8 sUnknown_03000E18; +static u8 sRfuKeepAliveTimer; +static u32 sUnusedVar; // IWRAM common u16 *gBGTilemapBuffers1; diff --git a/src/party_menu.c b/src/party_menu.c index f20bdff51..ad5807ce4 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1596,8 +1596,8 @@ static void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 messageId, TaskFunc task, M gUnknown_0203CEC4->task = task; gUnknown_0203CEC4->exitCallback = NULL; gUnknown_0203CEC4->unk8_1 = 0; - gUnknown_0203CEC4->unk8_2 = 0xFF; - gUnknown_0203CEC4->unk9_0 = 0xFF; + gUnknown_0203CEC4->unk8_2 = 0x7F; + gUnknown_0203CEC4->unk9_0 = 0x7F; if (a == 4) gUnknown_0203CEC4->unk8_0 = TRUE; diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 1eb8c0953..dc69b5d54 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -763,11 +763,11 @@ static void sub_813D6B4(void) static void CreateAreaMarkerSprites(void) { u8 spriteId; - static IWRAM_DATA s16 x; - static IWRAM_DATA s16 y; - static IWRAM_DATA s16 i; - static IWRAM_DATA s16 mapSecId; - static IWRAM_DATA s16 numSprites; + static s16 x; + static s16 y; + static s16 i; + static s16 mapSecId; + static s16 numSprites; LoadSpriteSheet(&sAreaMarkerSpriteSheet); LoadSpritePalette(&sAreaMarkerSpritePalette); diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index 52fa6db51..0929dfa44 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -177,9 +177,9 @@ static void SpriteCB_SetDummyOnAnimEnd(struct Sprite *sprite); #define STRUCT_COUNT 4 // IWRAM bss -static IWRAM_DATA struct UnkAnimStruct sUnknown_03001240[STRUCT_COUNT]; -static IWRAM_DATA u8 sUnknown_03001270; -static IWRAM_DATA bool32 sUnknown_03001274; +static struct UnkAnimStruct sUnknown_03001240[STRUCT_COUNT]; +static u8 sUnknown_03001270; +static bool32 sUnknown_03001274; // const rom data static const u8 sSpeciesToBackAnimSet[] = diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 0ddad55a6..49b171ec0 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -443,7 +443,7 @@ enum #define TAG_TILE_1 0x1 // IWRAM bss -IWRAM_DATA static u32 gUnknown_03000F78[98]; +static u32 gUnknown_03000F78[98]; // EWRAM DATA EWRAM_DATA static u8 sPreviousBoxOption = 0; diff --git a/src/random.c b/src/random.c index f0b2d9e5f..b570a7bc3 100644 --- a/src/random.c +++ b/src/random.c @@ -8,8 +8,8 @@ EWRAM_DATA static u8 sUnknown = 0; EWRAM_DATA static u32 sRandCount = 0; // IWRAM common -IWRAM_DATA u32 gRngValue; -IWRAM_DATA u32 gRng2Value; +u32 gRngValue; +u32 gRng2Value; u16 Random(void) { diff --git a/src/record_mixing.c b/src/record_mixing.c index 85b52e478..6cb145c80 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -82,21 +82,21 @@ union PlayerRecords // Static RAM declarations -static IWRAM_DATA bool8 gUnknown_03001130; -static IWRAM_DATA struct SecretBase *sSecretBasesSave; -static IWRAM_DATA TVShow *sTvShowsSave; -static IWRAM_DATA PokeNews *sPokeNewsSave; -static IWRAM_DATA OldMan *sOldManSave; -static IWRAM_DATA struct EasyChatPair *sEasyChatPairsSave; -static IWRAM_DATA struct RecordMixingDayCareMail *gUnknown_03001148; -static IWRAM_DATA void *sBattleTowerSave; -static IWRAM_DATA LilycoveLady *sLilycoveLadySave; -static IWRAM_DATA void *sApprenticesSave; -static IWRAM_DATA void *sBattleTowerSave_Duplicate; -static IWRAM_DATA u32 sRecordStructSize; -static IWRAM_DATA u8 gUnknown_03001160; -static IWRAM_DATA u32 filler_03001164; -static IWRAM_DATA struct PlayerHallRecords *gUnknown_03001168[3]; +static bool8 gUnknown_03001130; +static struct SecretBase *sSecretBasesSave; +static TVShow *sTvShowsSave; +static PokeNews *sPokeNewsSave; +static OldMan *sOldManSave; +static struct EasyChatPair *sEasyChatPairsSave; +static struct RecordMixingDayCareMail *gUnknown_03001148; +static void *sBattleTowerSave; +static LilycoveLady *sLilycoveLadySave; +static void *sApprenticesSave; +static void *sBattleTowerSave_Duplicate; +static u32 sRecordStructSize; +static u8 gUnknown_03001160; +static u32 filler_03001164; +static struct PlayerHallRecords *gUnknown_03001168[3]; static EWRAM_DATA struct RecordMixingDayCareMail gUnknown_02039F9C = {0}; static EWRAM_DATA union PlayerRecords *sReceivedRecords = NULL; diff --git a/src/recorded_battle.c b/src/recorded_battle.c index ac97dfcd6..9e03d57f6 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -100,8 +100,8 @@ EWRAM_DATA static u8 sApprenticeId = 0; EWRAM_DATA static u16 sEasyChatSpeech[6] = {0}; EWRAM_DATA static u8 sBattleOutcome = 0; -IWRAM_DATA static u8 sRecordMixFriendLanguage; -IWRAM_DATA static u8 sApprenticeLanguage; +static u8 sRecordMixFriendLanguage; +static u8 sApprenticeLanguage; // this file's functions static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2); diff --git a/src/reset_save_heap.c b/src/reset_save_heap.c index 95d63a323..beba742f5 100644 --- a/src/reset_save_heap.c +++ b/src/reset_save_heap.c @@ -14,7 +14,7 @@ void sub_81700F8(void) imeBackup = REG_IME; REG_IME = 0; - RegisterRamReset(0x00000001); + RegisterRamReset(RESET_EWRAM); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK); REG_IME = imeBackup; gMain.inBattle = FALSE; diff --git a/src/rom_8034C54.c b/src/rom_8034C54.c index a3707017e..42817fc2b 100644 --- a/src/rom_8034C54.c +++ b/src/rom_8034C54.c @@ -43,9 +43,9 @@ static bool32 SharesPalWithAnyActive(u32 id); static void sub_8035648(void); // iwram -static IWRAM_DATA s32 gUnknown_03000DD4; -static IWRAM_DATA s32 gUnknown_03000DD8; -static IWRAM_DATA s32 gUnknown_03000DDC; +static s32 gUnknown_03000DD4; +static s32 gUnknown_03000DD8; +static s32 gUnknown_03000DDC; // ewram static EWRAM_DATA struct UnkStruct1 *gUnknown_02022E10 = {0}; diff --git a/src/roulette_util.c b/src/roulette_util.c index 16c3e8150..f1f04a73a 100755 --- a/src/roulette_util.c +++ b/src/roulette_util.c @@ -408,8 +408,8 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend) } } break; - case 2: // Flip back and forth - // This code is never reached + case (MODERN ? -2 : 2): // Flip back and forth + // This code is never reached in vanilla if (pulseBlendPalette->fadeDirection) pulseBlendPalette->blendCoeff = 0; else diff --git a/src/rtc.c b/src/rtc.c index 37a06fe7e..b135a675a 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -4,10 +4,10 @@ #include "text.h" // iwram bss -IWRAM_DATA static u16 sErrorStatus; -IWRAM_DATA static struct SiiRtcInfo sRtc; -IWRAM_DATA static u8 sProbeResult; -IWRAM_DATA static u16 sSavedIme; +static u16 sErrorStatus; +static struct SiiRtcInfo sRtc; +static u8 sProbeResult; +static u16 sSavedIme; // iwram common struct Time gLocalTime; diff --git a/src/script.c b/src/script.c index 27476dba3..34484561c 100644 --- a/src/script.c +++ b/src/script.c @@ -10,12 +10,12 @@ extern const u8* gUnknown_020375C0; // ewram bss -IWRAM_DATA static u8 sScriptContext1Status; -IWRAM_DATA static u32 sUnusedVariable1; -IWRAM_DATA static struct ScriptContext sScriptContext1; -IWRAM_DATA static u32 sUnusedVariable2; -IWRAM_DATA static struct ScriptContext sScriptContext2; -IWRAM_DATA static bool8 sScriptContext2Enabled; +static u8 sScriptContext1Status; +static u32 sUnusedVariable1; +static struct ScriptContext sScriptContext1; +static u32 sUnusedVariable2; +static struct ScriptContext sScriptContext2; +static bool8 sScriptContext2Enabled; extern ScrCmdFunc gScriptCmdTable[]; extern ScrCmdFunc gScriptCmdTableEnd[]; diff --git a/src/slot_machine.c b/src/slot_machine.c index b853daa39..003ac3327 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -350,7 +350,7 @@ static EWRAM_DATA struct SpriteSheet *sUnknown_0203AB30 = NULL; static EWRAM_DATA struct SlotMachineEwramStruct *sSlotMachine = NULL; // IWRAM bss -static IWRAM_DATA struct SpriteFrameImage *gUnknown_03001188[26]; +static struct SpriteFrameImage *gUnknown_03001188[26]; // Const rom data. extern const struct UnkStruct1 *const gUnknown_083ED048[]; diff --git a/src/sound.c b/src/sound.c index 16f024858..dba4354df 100644 --- a/src/sound.c +++ b/src/sound.c @@ -19,11 +19,11 @@ EWRAM_DATA struct MusicPlayerInfo* gMPlay_PokemonCry = NULL; EWRAM_DATA u8 gPokemonCryBGMDuckingCounter = 0; // iwram bss -IWRAM_DATA static u16 sCurrentMapMusic; -IWRAM_DATA static u16 sNextMapMusic; -IWRAM_DATA static u8 sMapMusicState; -IWRAM_DATA static u8 sMapMusicFadeInSpeed; -IWRAM_DATA static u16 sFanfareCounter; +static u16 sCurrentMapMusic; +static u16 sNextMapMusic; +static u8 sMapMusicState; +static u8 sMapMusicFadeInSpeed; +static u16 sFanfareCounter; // iwram common bool8 gDisableMusic; diff --git a/src/sprite.c b/src/sprite.c index d2ea7889c..e25eac62e 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -285,10 +285,10 @@ static const struct OamDimensions sOamDimensions[3][4] = }; // iwram bss -IWRAM_DATA static u16 sSpriteTileRangeTags[MAX_SPRITES]; -IWRAM_DATA static u16 sSpriteTileRanges[MAX_SPRITES * 2]; -IWRAM_DATA static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT]; -IWRAM_DATA static u16 sSpritePaletteTags[16]; +static u16 sSpriteTileRangeTags[MAX_SPRITES]; +static u16 sSpriteTileRanges[MAX_SPRITES * 2]; +static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT]; +static u16 sSpritePaletteTags[16]; // iwram common u32 gOamMatrixAllocBitmap; diff --git a/src/starter_choose.c b/src/starter_choose.c index 886daa45a..5524d407b 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -51,7 +51,7 @@ void sub_81346DC(struct Sprite *sprite); void sub_813473C(struct Sprite *sprite); void StarterPokemonSpriteCallback(struct Sprite *sprite); -static IWRAM_DATA u16 sStarterChooseWindowId; +static u16 sStarterChooseWindowId; // .rodata const u16 gBirchBagGrassPal[][16] = From 255a5c1832ff26ef607c2bbada68294beb72a1e8 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Wed, 26 Jun 2019 16:44:36 -0400 Subject: [PATCH 05/19] Set travis to build the gcc-8 target --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ff4ab4bc9..bb03c0600 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,5 +32,6 @@ matrix: script: - ./build_tools.sh g++-7 - make -j2 compare + - make -j2 modern after_success: - .travis/calcrom/webhook.sh pokeemerald From 10a88b6a716a5ed75fd924da93015593e9f25296 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Wed, 26 Jun 2019 20:12:40 -0400 Subject: [PATCH 06/19] Simplify ld_script for modern, use devkitARM libs --- Makefile | 14 +++- ld_script_modern.txt | 162 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 ld_script_modern.txt diff --git a/Makefile b/Makefile index b23b278be..a47c45135 100644 --- a/Makefile +++ b/Makefile @@ -39,18 +39,20 @@ CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm ROM := pokeemerald.gba OBJ_DIR := build/emerald +LIBPATH := -L ../../tools/agbcc/lib else CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations -Wno-pointer-to-int-cast ROM := pokeemerald_modern.gba OBJ_DIR := build/modern +LIBPATH := -L $(DEVKITARM)/lib/gcc/arm-none-eabi/*/thumb -L $(DEVKITARM)/arm-none-eabi/lib/thumb endif CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -Wno-trigraphs -DMODERN=$(MODERN) LDFLAGS = -Map ../../$(MAP) -LIB := -L ../../tools/agbcc/lib -lgcc -lc +LIB := $(LIBPATH) -lgcc -lc SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c GFX := tools/gbagfx/gbagfx$(EXE) @@ -204,8 +206,14 @@ $(OBJ_DIR)/sym_common.ld: sym_common.txt $(C_OBJS) $(wildcard common_syms/*.txt) $(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt $(RAMSCRGEN) ewram_data $< ENGLISH > $@ -$(OBJ_DIR)/ld_script.ld: ld_script.txt $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld - cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../ld_script.txt > ld_script.ld +ifeq ($(MODERN),0) +LD_SCRIPT := ld_script.txt +else +LD_SCRIPT := ld_script_modern.txt +endif + +$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld + cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) diff --git a/ld_script_modern.txt b/ld_script_modern.txt new file mode 100644 index 000000000..22884ae44 --- /dev/null +++ b/ld_script_modern.txt @@ -0,0 +1,162 @@ +ENTRY(Start) + +gNumMusicPlayers = 4; +gMaxLines = 0; + +SECTIONS { + . = 0x2000000; + + ewram (NOLOAD) : + ALIGN(4) + { + gHeap = .; + + . = 0x1C000; + + INCLUDE "sym_ewram.ld" + + . = 0x40000; +} + + . = 0x3000000; + + iwram (NOLOAD) : + ALIGN(4) + { + /* .bss starts at 0x3000000 */ + INCLUDE "sym_bss.ld" + + /* .bss.code starts at 0x3001AA8 */ + src/m4a.o(.bss.code); + + /* COMMON starts at 0x30022A8 */ + INCLUDE "sym_common.ld" + *libc.a:sbrkr.o(COMMON); + end = .; + . = 0x8000; + } + + . = 0x8000000; + + .text : + ALIGN(4) + { + asm/crt0.o(.text); + src/*.o(.text); + asm/*.o(.text); + } =0 + + script_data : + ALIGN(4) + { + data/event_scripts.o(script_data); + data/battle_anim_scripts.o(script_data); + data/battle_scripts_1.o(script_data); + data/field_effect_scripts.o(script_data); + data/battle_scripts_2.o(script_data); + data/battle_ai_scripts.o(script_data); + data/contest_ai_scripts.o(script_data); + data/mystery_event_script_cmd_table.o(script_data); + } =0 + + lib_text : + ALIGN(4) + { + asm/libgcnmultiboot.o(.text); + asm/m4a_1.o(.text); + src/m4a.o(.text); + src/agb_flash.o(.text); + src/agb_flash_1m.o(.text); + src/agb_flash_mx.o(.text); + src/siirtc.o(.text); + src/librfu_stwi.o(.text); + src/librfu_intr.o(.text); + asm/librfu_intr.o(.text); + src/librfu_rfu.o(.text); + asm/librfu.o(.text); + asm/libagbsyscall.o(.text); + *libgcc.a:*.o(.text*); + *libc.a:*.o(.text*); + src/libisagbprn.o(.text); + } =0 + + .rodata : + ALIGN(4) + { + src/*.o(.rodata*); + data/*.o(.rodata*); + } =0 + + song_data : + ALIGN(4) + { + sound/songs/*.o(.rodata); + } =0 + + lib_rodata : + SUBALIGN(4) + { + src/m4a.o(.rodata); + src/agb_flash.o(.rodata); + src/agb_flash_1m.o(.rodata); + src/agb_flash_mx.o(.rodata); + src/agb_flash_le.o(.rodata); + src/siirtc.o(.rodata); + data/librfu_rodata.o(.rodata); + *libgcc.a:*.o(.rodata*); + *libc.a:*.o(.rodata*); + *libc.a:*.o(.data*); + src/libisagbprn.o(.rodata); + } =0 + + other_data : + ALIGN(4) + { + data/unknown_serial_data.o(.rodata); + data/multiboot_berry_glitch_fix.o(.rodata); + data/multiboot_pokemon_colosseum.o(.rodata); + } =0 + + anim_mon_front_pic_data : + ALIGN(4) + { + src/anim_mon_front_pics.o(.rodata); + } =0 + + gfx_data : + ALIGN(4) + { + src/graphics.o(.rodata); + } =0 + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + + /* Discard everything not specifically mentioned above. */ + /DISCARD/ : + { + *(*); + } +} From 7a02a9ef36c8b66e6fd176aa5afa5500d34a9b06 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Thu, 27 Jun 2019 06:55:50 -0400 Subject: [PATCH 07/19] Indentation fix in ld_scripts --- ld_script.txt | 4 ++-- ld_script_modern.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ld_script.txt b/ld_script.txt index b35b108ea..c9c747490 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -523,7 +523,7 @@ SECTIONS { src/record_mixing.o(.rodata); src/secret_base.o(.rodata); src/tv.o(.rodata); - src/contest_link_80F57C4.o(.rodata); + src/contest_link_80F57C4.o(.rodata); data/contest_link_80F57C4.o(.rodata); src/script_pokemon_util_80F87D8.o(.rodata); src/pokemon_size_record.o(.rodata) @@ -1214,7 +1214,7 @@ SECTIONS { lib_rodata : SUBALIGN(4) { - src/m4a.o(.rodata); + src/m4a.o(.rodata); src/agb_flash.o(.rodata); src/agb_flash_1m.o(.rodata); src/agb_flash_mx.o(.rodata); diff --git a/ld_script_modern.txt b/ld_script_modern.txt index 22884ae44..d38102de3 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.txt @@ -43,7 +43,7 @@ SECTIONS { { asm/crt0.o(.text); src/*.o(.text); - asm/*.o(.text); + asm/*.o(.text); } =0 script_data : @@ -84,19 +84,19 @@ SECTIONS { ALIGN(4) { src/*.o(.rodata*); - data/*.o(.rodata*); + data/*.o(.rodata*); } =0 song_data : ALIGN(4) { - sound/songs/*.o(.rodata); + sound/songs/*.o(.rodata); } =0 lib_rodata : SUBALIGN(4) { - src/m4a.o(.rodata); + src/m4a.o(.rodata); src/agb_flash.o(.rodata); src/agb_flash_1m.o(.rodata); src/agb_flash_mx.o(.rodata); From e92e9a184ccfa2aa3a226610d6c4e633e8082c10 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Fri, 28 Jun 2019 22:26:11 -0400 Subject: [PATCH 08/19] Support for non-dkA toolchains --- INSTALL.md | 13 +++++++++++++ Makefile | 16 +++++++++++++++- include/fieldmap.h | 4 ++-- include/global.h | 1 + include/link_rfu.h | 2 +- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index fcdd8b655..8825e49da 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -101,3 +101,16 @@ If you've only changed `.c` or `.s` files, you can turn off the dependency scann `make NODEP=1` +# Building with devkitARM's C compiler + +This project supports the `arm-none-eabi-gcc` compiler which ships with devkitARM r52. To build this target, simply run: + + make modern + +# Building with your own toolchain + +To build Pokemon Emerald with a toolchain other than devkitARM, override the `DEVKITARM` environment variable with the path to your toolchain. Example: + + make compare DEVKITARM=/usr/local/arm-none-eabi + +The path you pass to the `DEVKITARM` variable must contain the subdirectory `bin`. If you compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present. diff --git a/Makefile b/Makefile index a47c45135..1f974c770 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,11 @@ +ifneq (,$(wildcard $(DEVKITARM)/base_tools)) include $(DEVKITARM)/base_tools +else +PREFIX := $(DEVKITARM)/bin/arm-none-eabi- +OBJCOPY := $(PREFIX)objcopy +CC := $(PREFIX)gcc +AS := $(PREFIX)as +endif export CPP := $(PREFIX)cpp export LD := $(PREFIX)ld @@ -48,7 +55,14 @@ OBJ_DIR := build/modern LIBPATH := -L $(DEVKITARM)/lib/gcc/arm-none-eabi/*/thumb -L $(DEVKITARM)/arm-none-eabi/lib/thumb endif -CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -Wno-trigraphs -DMODERN=$(MODERN) +ifeq ($(DEBUG),1) +CFLAGS += -g +endif + +CPPFLAGS := -iquote include -Wno-trigraphs -DMODERN=$(MODERN) +ifeq ($(MODERN),0) +CPPFLAGS += -I tools/agbcc/include -I tools/agbcc +endif LDFLAGS = -Map ../../$(MAP) diff --git a/include/fieldmap.h b/include/fieldmap.h index 2384ed46a..be5610a46 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -23,9 +23,9 @@ int GetMapBorderIdAt(int x, int y); int CanCameraMoveInDirection(int direction); u16 GetBehaviorByMetatileId(u16 metatileId); void GetCameraFocusCoords(u16 *x, u16 *y); -u8 MapGridGetMetatileLayerTypeAt(s32 x, s32 y); +u8 MapGridGetMetatileLayerTypeAt(int x, int y); u8 MapGridGetZCoordAt(int x, int y); -u8 CameraMove(s32 deltaX, s32 deltaY); +bool8 CameraMove(int deltaX, int deltaY); struct MapConnection *sub_8088950(u8 direction, int x, int y); bool8 sub_80889A8(u8 direction, int x, int y, struct MapConnection *connection); bool8 sub_8088A0C(int x, int src_width, int dest_width, int offset); diff --git a/include/global.h b/include/global.h index 712a40866..a76d6e4e3 100644 --- a/include/global.h +++ b/include/global.h @@ -2,6 +2,7 @@ #define GUARD_GLOBAL_H #include <string.h> +#include <limits.h> #include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" #include "constants/global.h" diff --git a/include/link_rfu.h b/include/link_rfu.h index dc5b963d1..4bf106ec1 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -278,7 +278,7 @@ bool32 sub_8011B90(void); void sub_800FE50(u16 *a0); bool32 sub_800E540(u16 id, u8 *name); void sub_8011DE0(u32 arg0); -u8 sub_801100C(int a0); +u8 sub_801100C(s32 a0); void sub_800EF7C(void); bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx); bool8 sub_800DF34(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx); From 4b759da71413f3a2b63cb1c220fba4da490bf3d2 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sat, 29 Jun 2019 08:35:52 -0400 Subject: [PATCH 09/19] Wildcard bss, ewram_data, and COMMON in modern toolchain --- Makefile | 4 +++- common_syms/ereader_screen.txt | 1 + common_syms/librfu.txt | 6 ++++++ common_syms/librfu_stwi.txt | 1 + ld_script_modern.txt | 16 +++++----------- src/ereader_screen.c | 2 +- src/librfu.c | 9 +++++++++ src/librfu_intr.c | 1 + src/librfu_stwi.c | 2 ++ src/pokemon_jump.c | 4 ++-- src/pokenav_unk_10.c | 4 ++-- src/pokenav_unk_7.c | 3 +++ sym_bss.txt | 13 ++----------- sym_common.txt | 27 +++------------------------ sym_ewram.txt | 9 +-------- 15 files changed, 42 insertions(+), 60 deletions(-) create mode 100644 common_syms/ereader_screen.txt create mode 100644 common_syms/librfu.txt create mode 100644 common_syms/librfu_stwi.txt create mode 100644 src/librfu.c create mode 100644 src/pokenav_unk_7.c diff --git a/Makefile b/Makefile index 1f974c770..f22e6fc28 100644 --- a/Makefile +++ b/Makefile @@ -222,11 +222,13 @@ $(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt ifeq ($(MODERN),0) LD_SCRIPT := ld_script.txt +LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld else LD_SCRIPT := ld_script_modern.txt +LD_SCRIPT_DEPS := endif -$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld +$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS) cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) diff --git a/common_syms/ereader_screen.txt b/common_syms/ereader_screen.txt new file mode 100644 index 000000000..5a89d370d --- /dev/null +++ b/common_syms/ereader_screen.txt @@ -0,0 +1 @@ +gUnknown_03006370 diff --git a/common_syms/librfu.txt b/common_syms/librfu.txt new file mode 100644 index 000000000..e81d78795 --- /dev/null +++ b/common_syms/librfu.txt @@ -0,0 +1,6 @@ +gUnknown_03007870 +gUnknown_03007880 +gUnknown_03007890 +gUnknown_03007894 +gUnknown_03007898 +gUnknown_030078A0 diff --git a/common_syms/librfu_stwi.txt b/common_syms/librfu_stwi.txt new file mode 100644 index 000000000..0e8468f4d --- /dev/null +++ b/common_syms/librfu_stwi.txt @@ -0,0 +1 @@ +gRfuState diff --git a/ld_script_modern.txt b/ld_script_modern.txt index d38102de3..98ef16b17 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.txt @@ -13,7 +13,7 @@ SECTIONS { . = 0x1C000; - INCLUDE "sym_ewram.ld" + src/*.o(ewram_data); . = 0x40000; } @@ -24,13 +24,14 @@ SECTIONS { ALIGN(4) { /* .bss starts at 0x3000000 */ - INCLUDE "sym_bss.ld" + src/*.o(.bss); + asm/m4a_1.o(.bss); /* .bss.code starts at 0x3001AA8 */ src/m4a.o(.bss.code); /* COMMON starts at 0x30022A8 */ - INCLUDE "sym_common.ld" + src/*.o(COMMON); *libc.a:sbrkr.o(COMMON); end = .; . = 0x8000; @@ -49,14 +50,7 @@ SECTIONS { script_data : ALIGN(4) { - data/event_scripts.o(script_data); - data/battle_anim_scripts.o(script_data); - data/battle_scripts_1.o(script_data); - data/field_effect_scripts.o(script_data); - data/battle_scripts_2.o(script_data); - data/battle_ai_scripts.o(script_data); - data/contest_ai_scripts.o(script_data); - data/mystery_event_script_cmd_table.o(script_data); + data/*.o(script_data); } =0 lib_text : diff --git a/src/ereader_screen.c b/src/ereader_screen.c index f74efa32b..98f0d9b8c 100755 --- a/src/ereader_screen.c +++ b/src/ereader_screen.c @@ -38,7 +38,7 @@ struct Unk03006370 static void sub_81D5084(u8); -extern struct Unk03006370 gUnknown_03006370; +struct Unk03006370 gUnknown_03006370; extern const u8 gUnknown_089A3470[]; extern const u8 gMultiBootProgram_BerryGlitchFix_Start[]; diff --git a/src/librfu.c b/src/librfu.c new file mode 100644 index 000000000..cdf14b693 --- /dev/null +++ b/src/librfu.c @@ -0,0 +1,9 @@ +#include "global.h" +#include "librfu.h" + +struct RfuUnk1* gUnknown_03007870[4]; +struct RfuUnk2* gUnknown_03007880[4]; +struct RfuUnk5 *gUnknown_03007890; +u32 *gUnknown_03007894; +struct RfuUnk3* gUnknown_03007898; +u8 gUnknown_030078A0[12]; diff --git a/src/librfu_intr.c b/src/librfu_intr.c index bdf8b072a..c6db9a50c 100644 --- a/src/librfu_intr.c +++ b/src/librfu_intr.c @@ -1,4 +1,5 @@ #include "global.h" #include "main.h" +#include "librfu.h" //TODO: decompile asm/librfu_intr.s to here diff --git a/src/librfu_stwi.c b/src/librfu_stwi.c index 556b79bf8..670692118 100644 --- a/src/librfu_stwi.c +++ b/src/librfu_stwi.c @@ -1,6 +1,8 @@ #include "global.h" #include "librfu.h" +struct RfuStruct *gRfuState; + extern IntrFunc IntrSIO32(void); extern void STWI_stop_timer(void); diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 4a457adc4..3a64497bd 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -250,8 +250,8 @@ bool32 sub_802E2D0(struct PokemonJump1_82E4 *, int); int sub_802E354(int, u16, u16); void sub_802E3A8(void); -extern struct PokemonJump1 *gUnknown_02022CFC; -extern struct PokemonJump2 *gUnknown_02022D00; +EWRAM_DATA struct PokemonJump1 *gUnknown_02022CFC = NULL; +EWRAM_DATA struct PokemonJump2 *gUnknown_02022D00 = NULL; const struct PokemonJumpMons gPkmnJumpSpecies[] = { diff --git a/src/pokenav_unk_10.c b/src/pokenav_unk_10.c index dcdbacfb9..dd91e930a 100644 --- a/src/pokenav_unk_10.c +++ b/src/pokenav_unk_10.c @@ -36,8 +36,8 @@ extern const u8 gText_RibbonsF700[]; extern const u8 *const gRibbonDescriptionPointers[][2]; extern const u8 *const gGiftRibbonDescriptionPointers[][2]; -extern u32 gUnknown_030012C0; -extern u32 gUnknown_030012C4; +static u32 gUnknown_030012C0; +static u32 gUnknown_030012C4; void sub_81D0E84(struct Pokenav10Struct2 *structPtr); void sub_81D0FF0(struct Pokenav10Struct2 *structPtr); diff --git a/src/pokenav_unk_7.c b/src/pokenav_unk_7.c new file mode 100644 index 000000000..af48fbb1f --- /dev/null +++ b/src/pokenav_unk_7.c @@ -0,0 +1,3 @@ +#include "global.h" + +BSS_DATA u8 gUnknown_030012BC; diff --git a/sym_bss.txt b/sym_bss.txt index 037c8d892..4c974c3f6 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -47,17 +47,8 @@ .include "src/multiboot.o" .include "src/mirage_tower.o" .include "src/berry_fix_program.o" - - @ pokenav -gUnknown_030012BC: @ 30012BC - .space 0x4 - -gUnknown_030012C0: @ 30012C0 - .space 0x4 - -gUnknown_030012C4: @ 30012C4 - .space 0x4 - + .include "src/pokenav_unk_7.o" + .include "src/pokenav_unk_10.o" .include "src/ereader_helpers.o" .include "src/faraway_island.o" .include "asm/m4a_1.o" diff --git a/sym_common.txt b/sym_common.txt index 17dbf5c41..f277ed0f2 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -45,29 +45,8 @@ .space 0x44 -gUnknown_03006370: @ 3006370 - .space 0x10 - + .include "ereader_screen.o" .include "m4a.o" .include "agb_flash.o" - -gRfuState: @ 3007868 - .space 0x8 - -gUnknown_03007870: @ 3007870 - .space 0x10 - -gUnknown_03007880: @ 3007880 - .space 0x10 - -gUnknown_03007890: @ 3007890 - .space 0x4 - -gUnknown_03007894: @ 3007894 - .space 0x4 - -gUnknown_03007898: @ 3007898 - .space 0x8 - -gUnknown_030078A0: @ 30078A0 - .space 0xC + .include "librfu_stwi.o" + .include "librfu.o" diff --git a/sym_ewram.txt b/sym_ewram.txt index 5fbcba779..3de0c45cb 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -18,14 +18,7 @@ .include "src/berry_crush.o" .include "src/berry_powder.o" .include "src/dodrio_berry_picking.o" - - @ pokemon_jump -gUnknown_02022CFC: @ 2022CFC - .space 0x4 - -gUnknown_02022D00: @ 2022D00 - .space 0x4 - + .include "src/pokemon_jump.o" .include "src/main_menu.o" .include "src/battle_controllers.o" .include "src/rom_8034C54.o" From f9d8678db43c533cf08c84ae4ebc85738ff113ea Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sat, 29 Jun 2019 11:41:26 -0400 Subject: [PATCH 10/19] Additional fixes Rearrange gbafix to not modify file in the event of failure Fix bug where Dma3Manager may get stuck when compiled with gcc-9.1.0 --- Makefile | 4 ++-- src/dma3_manager.c | 2 +- tools/gbafix/gbafix.c | 41 ++++++++++++++++++++++++----------------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index f22e6fc28..326d81421 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ OBJ_DIR := build/emerald LIBPATH := -L ../../tools/agbcc/lib else CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations -Wno-pointer-to-int-cast +override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast ROM := pokeemerald_modern.gba OBJ_DIR := build/modern LIBPATH := -L $(DEVKITARM)/lib/gcc/arm-none-eabi/*/thumb -L $(DEVKITARM)/arm-none-eabi/lib/thumb @@ -233,7 +233,7 @@ $(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS) $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) - $(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent + $(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent $(ROM): $(ELF) $(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@ diff --git a/src/dma3_manager.c b/src/dma3_manager.c index f11bf33dd..43744883f 100644 --- a/src/dma3_manager.c +++ b/src/dma3_manager.c @@ -17,7 +17,7 @@ BSS_DATA struct u32 value; } gDma3Requests[MAX_DMA_REQUESTS]; -static bool8 gDma3ManagerLocked; +static volatile bool8 gDma3ManagerLocked; static u8 gDma3RequestCursor; void ClearDma3Requests(void) diff --git a/tools/gbafix/gbafix.c b/tools/gbafix/gbafix.c index b4ad15a88..179305b1b 100644 --- a/tools/gbafix/gbafix.c +++ b/tools/gbafix/gbafix.c @@ -138,6 +138,7 @@ int main(int argc, char *argv[]) char *argfile = 0; FILE *infile; int silent = 0; + int schedule_pad = 0; int size,bit; @@ -172,28 +173,27 @@ int main(int argc, char *argv[]) return -1; } + uint32_t sh_offset = 0; + // read file infile = fopen(argfile, "r+b"); if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; } - fseek(infile, 0, SEEK_SET); + fseek(infile, sh_offset, SEEK_SET); fread(&header, sizeof(header), 1, infile); // elf check - uint32_t sh_offset = 0; + Elf32_Shdr secHeader; if (memcmp(&header, ELFMAG, 4) == 0) { Elf32_Ehdr *elfHeader = (Elf32_Ehdr *)&header; fseek(infile, elfHeader->e_shoff, SEEK_SET); int i; for (i = 0; i < elfHeader->e_shnum; i++) { - Elf32_Shdr secHeader; fread(&secHeader, sizeof(Elf32_Shdr), 1, infile); - if (secHeader.sh_type == SHT_PROGBITS && secHeader.sh_addr == elfHeader->e_entry) { - fseek(infile, secHeader.sh_offset, SEEK_SET); - sh_offset = secHeader.sh_offset; - break; - } + if (secHeader.sh_type == SHT_PROGBITS && secHeader.sh_addr == elfHeader->e_entry) break; } if (i == elfHeader->e_shnum) { fprintf(stderr, "Error finding entry point!\n"); return 1; } + fseek(infile, secHeader.sh_offset, SEEK_SET); + sh_offset = secHeader.sh_offset; fread(&header, sizeof(header), 1, infile); } @@ -211,15 +211,7 @@ int main(int argc, char *argv[]) { case 'p': // pad { - fseek(infile, 0, SEEK_END); - size = ftell(infile); - for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break; - if (size != (1<<bit)) - { - int todo = (1<<(bit+1)) - size; - while (todo--) fputc(0xFF, infile); - } - fseek(infile, 0, SEEK_SET); + schedule_pad = 1; break; } @@ -299,6 +291,21 @@ int main(int argc, char *argv[]) header.complement = HeaderComplement(); //header.checksum = checksum_without_header + HeaderChecksum(); + if (schedule_pad) { + if (sh_offset != 0) { + fprintf(stderr, "Warning: Cannot safely pad an ELF\n"); + } else { + fseek(infile, 0, SEEK_END); + size = ftell(infile); + for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break; + if (size != (1<<bit)) + { + int todo = (1<<(bit+1)) - size; + while (todo--) fputc(0xFF, infile); + } + } + } + fseek(infile, sh_offset, SEEK_SET); fwrite(&header, sizeof(header), 1, infile); fclose(infile); From 8b73ba61ee504cb8501b971eca21c74d3838e058 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sat, 29 Jun 2019 18:32:04 -0400 Subject: [PATCH 11/19] Misc. changes use the TOOLCHAIN variable instead of overriding DEVKITARM remove redunant DEBUG variable, substitute DINFO --- INSTALL.md | 12 +++++++++--- Makefile | 17 +++++++---------- tools/gbafix/gbafix.c | 3 ++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 8825e49da..df7b28354 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -109,8 +109,14 @@ This project supports the `arm-none-eabi-gcc` compiler which ships with devkitAR # Building with your own toolchain -To build Pokemon Emerald with a toolchain other than devkitARM, override the `DEVKITARM` environment variable with the path to your toolchain. Example: +To build Pokemon Emerald with a toolchain other than devkitARM, override the `TOOLCHAIN` environment variable with the path to your toolchain. Example: - make compare DEVKITARM=/usr/local/arm-none-eabi + make compare TOOLCHAIN=/usr/local/arm-none-eabi -The path you pass to the `DEVKITARM` variable must contain the subdirectory `bin`. If you compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present. +The path you pass to the `TOOLCHAIN` variable must contain the subdirectory `bin`. If you compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present. + +# Building with debug info + +To build the ELF file with enhanced debug info, use the `DINFO` variable: + + make compare DINFO=1 diff --git a/Makefile b/Makefile index 326d81421..1cd5da85c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ -ifneq (,$(wildcard $(DEVKITARM)/base_tools)) -include $(DEVKITARM)/base_tools +TOOLCHAIN := $(DEVKITARM) +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools else -PREFIX := $(DEVKITARM)/bin/arm-none-eabi- +PREFIX := $(TOOLCHAIN)/bin/arm-none-eabi- OBJCOPY := $(PREFIX)objcopy CC := $(PREFIX)gcc AS := $(PREFIX)as @@ -52,11 +53,7 @@ CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast ROM := pokeemerald_modern.gba OBJ_DIR := build/modern -LIBPATH := -L $(DEVKITARM)/lib/gcc/arm-none-eabi/*/thumb -L $(DEVKITARM)/arm-none-eabi/lib/thumb -endif - -ifeq ($(DEBUG),1) -CFLAGS += -g +LIBPATH := -L $(TOOLCHAIN)/lib/gcc/arm-none-eabi/*/thumb -L $(TOOLCHAIN)/arm-none-eabi/lib/thumb endif CPPFLAGS := -iquote include -Wno-trigraphs -DMODERN=$(MODERN) @@ -123,7 +120,7 @@ compare: $(ROM) clean: tidy rm -f sound/direct_sound_samples/*.bin - rm -f $(SONG_OBJS) $(MID_OBJS) $(MID_SUBDIR)/*.s + rm -f $(MID_SUBDIR)/*.s find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} + rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc rm -f $(DATA_ASM_SUBDIR)/maps/connections.inc $(DATA_ASM_SUBDIR)/maps/events.inc $(DATA_ASM_SUBDIR)/maps/groups.inc $(DATA_ASM_SUBDIR)/maps/headers.inc @@ -132,9 +129,9 @@ clean: tidy tidy: rm -f $(ROM) $(ELF) $(MAP) + rm -r $(OBJ_DIR) ifeq ($(MODERN),0) @$(MAKE) tidy MODERN=1 - rm -r build/* endif include graphics_file_rules.mk diff --git a/tools/gbafix/gbafix.c b/tools/gbafix/gbafix.c index 179305b1b..9088cdc5f 100644 --- a/tools/gbafix/gbafix.c +++ b/tools/gbafix/gbafix.c @@ -33,6 +33,7 @@ History ------- + v1.07 - added support for ELF input, (PikalaxALT) v1.06 - added output silencing, (Diegoisawesome) v1.05 - added debug offset argument, (Diegoisawesome) v1.04 - converted to plain C, (WinterMute) @@ -50,7 +51,7 @@ #include <stdint.h> #include "elf.h" -#define VER "1.06" +#define VER "1.07" #define ARGV argv[arg] #define VALUE (ARGV+2) #define NUMBER strtoul(VALUE, NULL, 0) From 04c9793429f5590fbc40a2aea4bcaf1ae8671b37 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sun, 30 Jun 2019 13:49:24 -0400 Subject: [PATCH 12/19] Fix pokemon_animation.c --- src/pokemon_animation.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index 0929dfa44..a6d57b7de 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -861,16 +861,22 @@ u8 GetSpeciesBackAnimSet(u16 species) } #define tState data[0] -#define tPtrLO data[1] -#define tPtrHI data[2] +#define tPtrHi data[1] +#define tPtrLo data[2] #define tAnimId data[3] #define tSaved0 data[4] #define tSaved2 data[5] +#if MODERN +#define ANIM_SPRITE(taskId) ((struct Sprite *)((gTasks[taskId].tPtrHi << 16) | ((u16)gTasks[taskId].tPtrLo))) +#else +#define ANIM_SPRITE(taskId) ((struct Sprite *)((gTasks[taskId].tPtrHi << 16) | (gTasks[taskId].tPtrLo))) +#endif //MODERN + static void Task_HandleMonAnimation(u8 taskId) { u32 i; - struct Sprite *sprite = (struct Sprite*)(u32)((gTasks[taskId].tPtrLO << 0x10) | (gTasks[taskId].tPtrHI)); + struct Sprite *sprite = ANIM_SPRITE(taskId); if (gTasks[taskId].tState == 0) { @@ -900,8 +906,8 @@ static void Task_HandleMonAnimation(u8 taskId) void LaunchAnimationTaskForFrontSprite(struct Sprite *sprite, u8 frontAnimId) { u8 taskId = CreateTask(Task_HandleMonAnimation, 128); - gTasks[taskId].tPtrLO = (u32)(sprite) >> 0x10; - gTasks[taskId].tPtrHI = (u32)(sprite); + gTasks[taskId].tPtrHi = (u32)(sprite) >> 0x10; + gTasks[taskId].tPtrLo = (u32)(sprite); gTasks[taskId].tAnimId = frontAnimId; } @@ -916,8 +922,8 @@ void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimSet) u8 nature, taskId, animId, battlerId; taskId = CreateTask(Task_HandleMonAnimation, 128); - gTasks[taskId].tPtrLO = (u32)(sprite) >> 0x10; - gTasks[taskId].tPtrHI = (u32)(sprite); + gTasks[taskId].tPtrHi = (u32)(sprite) >> 0x10; + gTasks[taskId].tPtrLo = (u32)(sprite); battlerId = sprite->data[0]; nature = GetNature(&gPlayerParty[gBattlerPartyIndexes[battlerId]]); @@ -927,8 +933,8 @@ void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimSet) } #undef tState -#undef tPtrLO -#undef tPtrHI +#undef tPtrHi +#undef tPtrLo #undef tAnimId #undef tSaved0 #undef tSaved2 From 92f17e88120b01ff57f02fe13696556419b4221c Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sun, 30 Jun 2019 19:19:26 -0400 Subject: [PATCH 13/19] Document pokemon_animations sprite ptr bug --- src/pokemon_animation.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index a6d57b7de..340327475 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -867,6 +867,11 @@ u8 GetSpeciesBackAnimSet(u16 species) #define tSaved0 data[4] #define tSaved2 data[5] +// BUG: In vanilla, tPtrLo is read as an s16, so if bit 15 of the +// address were to be set it would cause the pointer to be read +// as 0xFFFFXXXX instead of the desired 0x02YYXXXX. +// By dumb luck, this is not an issue in vanilla. However, +// changing the link order revealed this bug. #if MODERN #define ANIM_SPRITE(taskId) ((struct Sprite *)((gTasks[taskId].tPtrHi << 16) | ((u16)gTasks[taskId].tPtrLo))) #else From f300f9e699c6f90c7f8da3a4e130a21f231073a0 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sun, 30 Jun 2019 19:31:29 -0400 Subject: [PATCH 14/19] Revert FLOAT_U* and DOUBLE_U* macros --- include/gba/macro.h | 25 ------------------------- src/pokemon_size_record.c | 2 +- src/roulette.c | 10 +++++----- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/include/gba/macro.h b/include/gba/macro.h index 197febede..3b35a1946 100644 --- a/include/gba/macro.h +++ b/include/gba/macro.h @@ -192,29 +192,4 @@ REG_IME = imeTemp; \ } \ -#if MODERN -#define FLOAT_UNS(x, bit) ({ \ - s##bit sx = x; \ - float fx = (float)sx; \ - if (sx < 0) fx += (1 << (bit - 1)) * 2.0f; \ - fx; \ -}) -#define DOUBLE_UNS(x, bit) ({ \ - s##bit sx = x; \ - double dx = (double)sx; \ - if (sx < 0) dx += (1 << (bit - 1)) * 2.0; \ - dx; \ -}) -#else -#define FLOAT_UNS(x, bit) ((float)(x)) -#define DOUBLE_UNS(x, bit) ((double)(x)) -#endif //MODERN - -#define FLOAT_U8(x) FLOAT_UNS(x, 8) -#define FLOAT_U16(x) FLOAT_UNS(x, 16) -#define FLOAT_U32(x) FLOAT_UNS(x, 32) -#define DOUBLE_U8(x) DOUBLE_UNS(x, 8) -#define DOUBLE_U16(x) DOUBLE_UNS(x, 16) -#define DOUBLE_U32(x) DOUBLE_UNS(x, 32) - #endif // GUARD_GBA_MACRO_H diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index d70f57f47..f63e1ccba 100644 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -97,7 +97,7 @@ static void FormatMonSizeRecord(u8 *string, u32 size) { #ifdef UNITS_IMPERIAL //Convert size from centimeters to inches - size = DOUBLE_U32(size * 10) / (CM_PER_INCH * 10); + size = (double)(size * 10) / (CM_PER_INCH * 10); #endif string = ConvertIntToDecimalStringN(string, size / 10, 0, 8); diff --git a/src/roulette.c b/src/roulette.c index 5225118d5..662522aae 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -3969,7 +3969,7 @@ static void sub_8144410(struct Sprite *sprite) if (!sub_8143B48(sprite)) { gUnknown_0203AB88->var90 = 0.0f; - gUnknown_0203AB88->var8C -= FLOAT_U8(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var03) + gUnknown_0203AB88->var8C -= (float)(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var03) / (gUnknown_085B6348[gUnknown_0203AB88->var04_0].var04 + 1); sprite->data[1] = 4; sprite->callback = sub_8144264; @@ -3994,8 +3994,8 @@ static void sub_8144514(struct Sprite *sprite) if (gUnknown_0203AB88->var94 > 40.f) return; - gUnknown_0203AB88->var98 = -(4.0f / FLOAT_U16(gUnknown_0203AB88->var86)); - gUnknown_0203AB88->var90 = -(gUnknown_0203AB88->var8C / FLOAT_U16(gUnknown_0203AB88->var86)); + gUnknown_0203AB88->var98 = -(4.0f / (float)(gUnknown_0203AB88->var86)); + gUnknown_0203AB88->var90 = -(gUnknown_0203AB88->var8C / (float)(gUnknown_0203AB88->var86)); sprite->animNum = 2; sprite->animBeginning = TRUE; sprite->animEnded = FALSE; @@ -4010,8 +4010,8 @@ static void sub_81445D8(struct Sprite *sprite) return; m4aSongNumStartOrChange(SE_TAMAKORO_E); - gUnknown_0203AB88->var98 = -(20.0f / FLOAT_U16(gUnknown_0203AB88->var84)); - gUnknown_0203AB88->var90 = ((1.0f - gUnknown_0203AB88->var8C) / FLOAT_U16(gUnknown_0203AB88->var84)); + gUnknown_0203AB88->var98 = -(20.0f / (float)(gUnknown_0203AB88->var84)); + gUnknown_0203AB88->var90 = ((1.0f - gUnknown_0203AB88->var8C) / (float)(gUnknown_0203AB88->var84)); sprite->animNum = 1; sprite->animBeginning = TRUE; sprite->animEnded = FALSE; From 17c76432f420de962628e5c558ae2d4dee51dab7 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Tue, 2 Jul 2019 13:46:53 -0400 Subject: [PATCH 15/19] Fix libgcc path --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1cd5da85c..b6b50271b 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,8 @@ MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR) ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) +GCC_VER := $(shell $(CC) -dumpversion) + ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm @@ -49,11 +51,11 @@ ROM := pokeemerald.gba OBJ_DIR := build/emerald LIBPATH := -L ../../tools/agbcc/lib else -CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast +CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -quiet +override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast ROM := pokeemerald_modern.gba OBJ_DIR := build/modern -LIBPATH := -L $(TOOLCHAIN)/lib/gcc/arm-none-eabi/*/thumb -L $(TOOLCHAIN)/arm-none-eabi/lib/thumb +LIBPATH := -L $(TOOLCHAIN)/lib/gcc/arm-none-eabi/$(GCC_VER)/thumb -L $(TOOLCHAIN)/arm-none-eabi/lib/thumb endif CPPFLAGS := -iquote include -Wno-trigraphs -DMODERN=$(MODERN) From 7fd327d63279bb01492da57be6d6091be435d19c Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sun, 7 Jul 2019 21:07:30 -0400 Subject: [PATCH 16/19] Stack-free IWRAM clear --- src/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 47a957ce0..06425e661 100644 --- a/src/main.c +++ b/src/main.c @@ -89,7 +89,20 @@ void AgbMain() // Modern compilers are liberal with the stack on entry to this function, // so RegisterRamReset may crash if it resets IWRAM. RegisterRamReset(RESET_ALL & ~RESET_IWRAM); - DmaFill32(3, 0, IWRAM_START, 0x7E00); + asm("mov\tr1, #0xC0\n" + "\tlsl\tr1, r1, #0x12\n" + "\tmov r2, #0xFC\n" + "\tlsl r2, r2, #0x7\n" + "\tadd\tr2, r1, r2\n" + "\tmov\tr0, #0\n" + "\tmov\tr3, r0\n" + "\tmov\tr4, r0\n" + "\tmov\tr5, r0\n" + ".LCU0:\n" + "\tstmia r1!, {r0, r3, r4, r5}\n" + "\tcmp\tr1, r2\n" + "\tbcc\t.LCU0\n" + ); #else RegisterRamReset(RESET_ALL); #endif //MODERN From 20863ac85bcf047feeeba8295d0f9bcecef6f636 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Thu, 18 Jul 2019 20:46:00 -0400 Subject: [PATCH 17/19] Resolve compile warnings in modern --- include/pokenav.h | 4 +- include/text.h | 6 +- ld_script.txt | 702 +++++++++++++++++------------------ src/battle_main.c | 3 + src/cable_car.c | 2 +- src/item.c | 3 + src/item_menu.c | 4 +- src/party_menu.c | 2 +- src/pokemon_storage_system.c | 3 + src/pokenav_main_menu.c | 44 +-- src/pokenav_unk_3.c | 4 +- src/pokenav_unk_4.c | 34 +- src/pokenav_unk_5.c | 8 +- src/secret_base.c | 4 +- src/shop.c | 8 +- src/trade.c | 7 +- src/tv.c | 4 +- 17 files changed, 430 insertions(+), 412 deletions(-) diff --git a/include/pokenav.h b/include/pokenav.h index c840fd494..203d14015 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -4,7 +4,7 @@ #include "bg.h" #include "main.h" -typedef u32 (*LoopedTask)(int state); +typedef u32 (*LoopedTask)(s32 state); // Return values of LoopedTask functions. #define LT_INC_AND_PAUSE 0 @@ -111,7 +111,7 @@ void sub_81C7850(u32 a0); u32 sub_81C786C(void); void LoadLeftHeaderGfxForIndex(u32 arg0); void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2); -void sub_81C7AC0(int a0); +void sub_81C7AC0(s32 a0); bool32 sub_81C8010(void); void InitBgTemplates(const struct BgTemplate *templates, int count); bool32 IsPaletteFadeActive(void); diff --git a/include/text.h b/include/text.h index eba3d0c4e..d3ff663bb 100644 --- a/include/text.h +++ b/include/text.h @@ -166,7 +166,11 @@ struct TextPrinter void (*callback)(struct TextPrinterTemplate *, u16); // 0x10 - union __attribute__((packed)) { + union +#if !MODERN + __attribute__((packed)) +#endif + { struct TextPrinterSubStruct sub; u8 fields[7]; } subUnion; diff --git a/ld_script.txt b/ld_script.txt index c9c747490..42a94e9aa 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -41,293 +41,293 @@ SECTIONS { .text : ALIGN(4) { - asm/crt0.o(.text); - src/main.o(.text); - src/alloc.o(.text); - src/dma3_manager.o(.text); - src/gpu_regs.o(.text); - src/bg.o(.text); - src/blit.o(.text); - src/window.o(.text); - src/text.o(.text); - src/sprite.o(.text); - src/string_util.o(.text); - src/link.o(.text); - src/link_rfu.o(.text); - src/union_room.o(.text); - src/mystery_gift.o(.text); - src/union_room_player_avatar.o(.text); - src/union_room_battle.o(.text); - src/mevent2.o(.text); - src/mevent_801BAAC.o(.text); - src/mevent_server.o(.text); - src/mevent_client.o(.text); - src/mevent_server_helpers.o(.text); - src/mevent_news.o(.text); - src/union_room_chat.o(.text); - src/berry_crush.o(.text); - asm/berry_crush.o(.text); - src/berry_powder.o(.text); - src/dodrio_berry_picking.o(.text); - asm/dodrio_berry_picking.o(.text); - src/pokemon_jump.o(.text); - asm/pokemon_jump.o(.text); - src/rtc.o(.text); - src/main_menu.o(.text); - src/battle_controllers.o(.text); - src/decompress.o(.text); - src/rom_8034C54.o(.text); - src/battle_bg.o(.text); - src/battle_main.o(.text); - src/battle_util.o(.text); - src/battle_script_commands.o(.text); - src/battle_util2.o(.text); - src/battle_controller_player.o(.text); - src/battle_gfx_sfx_util.o(.text); - src/battle_controller_opponent.o(.text); - src/battle_ai_switch_items.o(.text); - src/battle_controller_link_opponent.o(.text); - src/pokemon.o(.text); - src/trig.o(.text); - src/random.o(.text); - src/util.o(.text); - src/daycare.o(.text); - src/egg_hatch.o(.text); - src/battle_interface.o(.text); - src/smokescreen.o(.text); - src/pokeball.o(.text); - src/load_save.o(.text); - src/trade.o(.text); - src/berry_blender.o(.text); - src/play_time.o(.text); - src/new_game.o(.text); - src/overworld.o(.text); - src/fieldmap.o(.text); - src/metatile_behavior.o(.text); - src/field_camera.o(.text); - src/field_door.o(.text); - src/field_player_avatar.o(.text); - src/event_object_movement.o(.text); - src/field_message_box.o(.text); - src/event_obj_lock.o(.text); - src/text_window.o(.text); - src/script.o(.text); - src/scrcmd.o(.text); - src/field_control_avatar.o(.text); - src/event_data.o(.text); - src/coord_event_weather.o(.text); - src/field_tasks.o(.text); - src/clock.o(.text); - src/reset_rtc_screen.o(.text); - src/start_menu.o(.text); - src/tileset_anims.o(.text); - src/palette.o(.text); - src/sound.o(.text); - src/battle_anim.o(.text); - src/battle_anim_mons.o(.text); - src/task.o(.text); - src/reshow_battle_screen.o(.text); - src/battle_anim_status_effects.o(.text); - src/title_screen.o(.text); - src/field_weather.o(.text); - src/field_weather_effect.o(.text); - src/field_screen_effect.o(.text); - src/battle_setup.o(.text); - src/cable_club.o(.text); - src/trainer_see.o(.text); - src/wild_encounter.o(.text); - src/field_effect.o(.text); - src/scanline_effect.o(.text); - src/option_menu.o(.text); - src/pokedex.o(.text); - src/trainer_card.o(.text); - src/frontier_pass.o(.text); - src/pokemon_storage_system.o(.text); - src/pokemon_icon.o(.text); - src/script_movement.o(.text); - src/fldeff_cut.o(.text); - src/mail_data.o(.text); - src/map_name_popup.o(.text); - src/item_menu_icons.o(.text); - src/battle_anim_mon_movement.o(.text); - src/item.o(.text); - src/contest.o(.text); - src/shop.o(.text); - src/fldeff_escalator.o(.text); - src/berry.o(.text); - src/script_menu.o(.text); - src/naming_screen.o(.text); - src/money.o(.text); - src/contest_effect.o(.text); - src/record_mixing.o(.text); - src/secret_base.o(.text); - src/tv.o(.text); - src/contest_link_80F57C4.o(.text); - src/script_pokemon_util_80F87D8.o(.text); - src/field_poison.o(.text); - src/pokemon_size_record.o(.text); - src/fldeff_misc.o(.text); - src/field_special_scene.o(.text); - src/rotating_gate.o(.text); - src/safari_zone.o(.text); - src/contest_link_80FC4F4.o(.text); - src/item_use.o(.text); - src/battle_anim_effects_1.o(.text); - src/battle_anim_effects_2.o(.text); - src/water.o(.text); - src/fire.o(.text); - src/electric.o(.text); - src/ice.o(.text); - src/fight.o(.text); - src/poison.o(.text); - src/flying.o(.text); - src/psychic.o(.text); - src/bug.o(.text); - src/rock.o(.text); - src/ghost.o(.text); - src/dragon.o(.text); - src/dark.o(.text); - src/ground.o(.text); - src/normal.o(.text); - src/battle_anim_utility_funcs.o(.text); - src/battle_intro.o(.text); - src/bike.o(.text); - src/easy_chat.o(.text); - src/mon_markings.o(.text); - src/mauville_old_man.o(.text); - src/mail.o(.text); - src/menu_helpers.o(.text); - src/dewford_trend.o(.text); - src/heal_location.o(.text); - src/region_map.o(.text); - src/contest_painting_effects.o(.text); - src/decoration.o(.text); - src/slot_machine.o(.text); - src/contest_painting.o(.text); - src/battle_ai_script_commands.o(.text); - src/trader.o(.text); - src/starter_choose.o(.text); - src/wallclock.o(.text); - src/fldeff_rocksmash.o(.text); - src/fldeff_dig.o(.text); - src/pokeblock.o(.text); - src/fldeff_flash.o(.text); - src/post_battle_event_funcs.o(.text); - src/time_events.o(.text); - src/birch_pc.o(.text); - src/hof_pc.o(.text); - src/field_specials.o(.text); - src/battle_records.o(.text); - src/pokedex_area_screen.o(.text); - src/evolution_scene.o(.text); - src/roulette.o(.text); - src/pokedex_cry_screen.o(.text); - src/coins.o(.text); - src/landmark.o(.text); - src/fldeff_strength.o(.text); - src/battle_transition.o(.text); - src/battle_controller_link_partner.o(.text); - src/battle_message.o(.text); - src/cable_car.o(.text); - src/math_util.o(.text); - src/roulette_util.o(.text); - src/rom_81520A8.o(.text); - src/save.o(.text); - src/mystery_event_script.o(.text); - src/field_effect_helpers.o(.text); - src/contest_ai.o(.text); - src/battle_anim_sound_tasks.o(.text); - src/battle_controller_safari.o(.text); - src/fldeff_sweetscent.o(.text); - src/battle_anim_effects_3.o(.text); - src/move_relearner.o(.text); - src/fldeff_softboiled.o(.text); - src/decoration_inventory.o(.text); - src/roamer.o(.text); - src/battle_tower.o(.text); - src/use_pokeblock.o(.text); - src/battle_controller_wally.o(.text); - src/player_pc.o(.text); - src/intro.o(.text); - src/reset_save_heap.o(.text); - src/field_region_map.o(.text); - src/battle_anim_special.o(.text); - src/hall_of_fame.o(.text); - src/credits.o(.text); - src/lottery_corner.o(.text); - src/diploma.o(.text); - src/berry_tag_screen.o(.text); - src/mystery_event_menu.o(.text); - src/save_failed_screen.o(.text); - src/braille_puzzles.o(.text); - src/pokeblock_feed.o(.text); - src/clear_save_data_screen.o(.text); - src/intro_credits_graphics.o(.text); - src/evolution_graphics.o(.text); - src/bard_music.o(.text); - src/fldeff_teleport.o(.text); - src/battle_tv.o(.text); - src/pokemon_animation.o(.text); - src/recorded_battle.o(.text); - src/battle_controller_recorded_opponent.o(.text); - src/battle_controller_recorded_player.o(.text); - src/trainer_pokemon_sprites.o(.text); - src/lilycove_lady.o(.text); - src/battle_dome.o(.text); - src/battle_palace.o(.text); - src/match_call.o(.text); - src/menu.o(.text); - src/battle_factory_screen.o(.text); - src/apprentice.o(.text); - src/frontier_util.o(.text); - src/battle_arena.o(.text); - src/battle_factory.o(.text); - src/battle_pike.o(.text); - src/mossdeep_gym.o(.text); - src/battle_pyramid.o(.text); - src/item_menu.o(.text); - src/list_menu.o(.text); - src/dynamic_placeholder_text_util.o(.text); - src/save_location.o(.text); - src/item_icon.o(.text); - src/party_menu.o(.text); - src/battle_tent.o(.text); - src/unk_text_util_2.o(.text); - src/multiboot.o(.text); - src/unk_81BAD84.o(.text); - src/battle_controller_player_partner.o(.text); - src/mirage_tower.o(.text); - src/berry_fix_program.o(.text); - src/pokemon_summary_screen.o(.text); - src/unk_pokedex_area_screen_helper.o(.text); - src/battle_pyramid_bag.o(.text); - src/pokenav.o(.text); - src/pokenav_main_menu.o(.text); - src/pokenav_match_call_ui.o(.text); - src/pokenav_unk_1.o(.text); - src/pokenav_unk_2.o(.text); - asm/pokenav_unk_2.o(.text); - src/pokenav_unk_3.o(.text); - src/pokenav_unk_4.o(.text); - src/pokenav_unk_5.o(.text); - asm/pokenav_unk_6.o(.text); - asm/pokenav_unk_7.o(.text); - asm/pokenav_unk_8.o(.text); - asm/pokenav_unk_9.o(.text); - asm/pokenav_unk_10.o(.text); - src/pokenav_unk_10.o(.text); - src/pokenav_match_call_data.o(.text); - src/menu_specialized.o(.text); - src/ereader_helpers.o(.text); - src/faraway_island.o(.text); - src/ereader_screen.o(.text); - src/trainer_hill.o(.text); - src/rayquaza_scene.o(.text); - src/walda_phrase.o(.text); - src/contest_link_81D9DE4.o(.text); - src/gym_leader_rematch.o(.text); - src/unk_transition.o(.text); - src/international_string_util.o(.text); + asm/crt0.o(.text*); + src/main.o(.text*); + src/alloc.o(.text*); + src/dma3_manager.o(.text*); + src/gpu_regs.o(.text*); + src/bg.o(.text*); + src/blit.o(.text*); + src/window.o(.text*); + src/text.o(.text*); + src/sprite.o(.text*); + src/string_util.o(.text*); + src/link.o(.text*); + src/link_rfu.o(.text*); + src/union_room.o(.text*); + src/mystery_gift.o(.text*); + src/union_room_player_avatar.o(.text*); + src/union_room_battle.o(.text*); + src/mevent2.o(.text*); + src/mevent_801BAAC.o(.text*); + src/mevent_server.o(.text*); + src/mevent_client.o(.text*); + src/mevent_server_helpers.o(.text*); + src/mevent_news.o(.text*); + src/union_room_chat.o(.text*); + src/berry_crush.o(.text*); + asm/berry_crush.o(.text*); + src/berry_powder.o(.text*); + src/dodrio_berry_picking.o(.text*); + asm/dodrio_berry_picking.o(.text*); + src/pokemon_jump.o(.text*); + asm/pokemon_jump.o(.text*); + src/rtc.o(.text*); + src/main_menu.o(.text*); + src/battle_controllers.o(.text*); + src/decompress.o(.text*); + src/rom_8034C54.o(.text*); + src/battle_bg.o(.text*); + src/battle_main.o(.text*); + src/battle_util.o(.text*); + src/battle_script_commands.o(.text*); + src/battle_util2.o(.text*); + src/battle_controller_player.o(.text*); + src/battle_gfx_sfx_util.o(.text*); + src/battle_controller_opponent.o(.text*); + src/battle_ai_switch_items.o(.text*); + src/battle_controller_link_opponent.o(.text*); + src/pokemon.o(.text*); + src/trig.o(.text*); + src/random.o(.text*); + src/util.o(.text*); + src/daycare.o(.text*); + src/egg_hatch.o(.text*); + src/battle_interface.o(.text*); + src/smokescreen.o(.text*); + src/pokeball.o(.text*); + src/load_save.o(.text*); + src/trade.o(.text*); + src/berry_blender.o(.text*); + src/play_time.o(.text*); + src/new_game.o(.text*); + src/overworld.o(.text*); + src/fieldmap.o(.text*); + src/metatile_behavior.o(.text*); + src/field_camera.o(.text*); + src/field_door.o(.text*); + src/field_player_avatar.o(.text*); + src/event_object_movement.o(.text*); + src/field_message_box.o(.text*); + src/event_obj_lock.o(.text*); + src/text_window.o(.text*); + src/script.o(.text*); + src/scrcmd.o(.text*); + src/field_control_avatar.o(.text*); + src/event_data.o(.text*); + src/coord_event_weather.o(.text*); + src/field_tasks.o(.text*); + src/clock.o(.text*); + src/reset_rtc_screen.o(.text*); + src/start_menu.o(.text*); + src/tileset_anims.o(.text*); + src/palette.o(.text*); + src/sound.o(.text*); + src/battle_anim.o(.text*); + src/battle_anim_mons.o(.text*); + src/task.o(.text*); + src/reshow_battle_screen.o(.text*); + src/battle_anim_status_effects.o(.text*); + src/title_screen.o(.text*); + src/field_weather.o(.text*); + src/field_weather_effect.o(.text*); + src/field_screen_effect.o(.text*); + src/battle_setup.o(.text*); + src/cable_club.o(.text*); + src/trainer_see.o(.text*); + src/wild_encounter.o(.text*); + src/field_effect.o(.text*); + src/scanline_effect.o(.text*); + src/option_menu.o(.text*); + src/pokedex.o(.text*); + src/trainer_card.o(.text*); + src/frontier_pass.o(.text*); + src/pokemon_storage_system.o(.text*); + src/pokemon_icon.o(.text*); + src/script_movement.o(.text*); + src/fldeff_cut.o(.text*); + src/mail_data.o(.text*); + src/map_name_popup.o(.text*); + src/item_menu_icons.o(.text*); + src/battle_anim_mon_movement.o(.text*); + src/item.o(.text*); + src/contest.o(.text*); + src/shop.o(.text*); + src/fldeff_escalator.o(.text*); + src/berry.o(.text*); + src/script_menu.o(.text*); + src/naming_screen.o(.text*); + src/money.o(.text*); + src/contest_effect.o(.text*); + src/record_mixing.o(.text*); + src/secret_base.o(.text*); + src/tv.o(.text*); + src/contest_link_80F57C4.o(.text*); + src/script_pokemon_util_80F87D8.o(.text*); + src/field_poison.o(.text*); + src/pokemon_size_record.o(.text*); + src/fldeff_misc.o(.text*); + src/field_special_scene.o(.text*); + src/rotating_gate.o(.text*); + src/safari_zone.o(.text*); + src/contest_link_80FC4F4.o(.text*); + src/item_use.o(.text*); + src/battle_anim_effects_1.o(.text*); + src/battle_anim_effects_2.o(.text*); + src/water.o(.text*); + src/fire.o(.text*); + src/electric.o(.text*); + src/ice.o(.text*); + src/fight.o(.text*); + src/poison.o(.text*); + src/flying.o(.text*); + src/psychic.o(.text*); + src/bug.o(.text*); + src/rock.o(.text*); + src/ghost.o(.text*); + src/dragon.o(.text*); + src/dark.o(.text*); + src/ground.o(.text*); + src/normal.o(.text*); + src/battle_anim_utility_funcs.o(.text*); + src/battle_intro.o(.text*); + src/bike.o(.text*); + src/easy_chat.o(.text*); + src/mon_markings.o(.text*); + src/mauville_old_man.o(.text*); + src/mail.o(.text*); + src/menu_helpers.o(.text*); + src/dewford_trend.o(.text*); + src/heal_location.o(.text*); + src/region_map.o(.text*); + src/contest_painting_effects.o(.text*); + src/decoration.o(.text*); + src/slot_machine.o(.text*); + src/contest_painting.o(.text*); + src/battle_ai_script_commands.o(.text*); + src/trader.o(.text*); + src/starter_choose.o(.text*); + src/wallclock.o(.text*); + src/fldeff_rocksmash.o(.text*); + src/fldeff_dig.o(.text*); + src/pokeblock.o(.text*); + src/fldeff_flash.o(.text*); + src/post_battle_event_funcs.o(.text*); + src/time_events.o(.text*); + src/birch_pc.o(.text*); + src/hof_pc.o(.text*); + src/field_specials.o(.text*); + src/battle_records.o(.text*); + src/pokedex_area_screen.o(.text*); + src/evolution_scene.o(.text*); + src/roulette.o(.text*); + src/pokedex_cry_screen.o(.text*); + src/coins.o(.text*); + src/landmark.o(.text*); + src/fldeff_strength.o(.text*); + src/battle_transition.o(.text*); + src/battle_controller_link_partner.o(.text*); + src/battle_message.o(.text*); + src/cable_car.o(.text*); + src/math_util.o(.text*); + src/roulette_util.o(.text*); + src/rom_81520A8.o(.text*); + src/save.o(.text*); + src/mystery_event_script.o(.text*); + src/field_effect_helpers.o(.text*); + src/contest_ai.o(.text*); + src/battle_anim_sound_tasks.o(.text*); + src/battle_controller_safari.o(.text*); + src/fldeff_sweetscent.o(.text*); + src/battle_anim_effects_3.o(.text*); + src/move_relearner.o(.text*); + src/fldeff_softboiled.o(.text*); + src/decoration_inventory.o(.text*); + src/roamer.o(.text*); + src/battle_tower.o(.text*); + src/use_pokeblock.o(.text*); + src/battle_controller_wally.o(.text*); + src/player_pc.o(.text*); + src/intro.o(.text*); + src/reset_save_heap.o(.text*); + src/field_region_map.o(.text*); + src/battle_anim_special.o(.text*); + src/hall_of_fame.o(.text*); + src/credits.o(.text*); + src/lottery_corner.o(.text*); + src/diploma.o(.text*); + src/berry_tag_screen.o(.text*); + src/mystery_event_menu.o(.text*); + src/save_failed_screen.o(.text*); + src/braille_puzzles.o(.text*); + src/pokeblock_feed.o(.text*); + src/clear_save_data_screen.o(.text*); + src/intro_credits_graphics.o(.text*); + src/evolution_graphics.o(.text*); + src/bard_music.o(.text*); + src/fldeff_teleport.o(.text*); + src/battle_tv.o(.text*); + src/pokemon_animation.o(.text*); + src/recorded_battle.o(.text*); + src/battle_controller_recorded_opponent.o(.text*); + src/battle_controller_recorded_player.o(.text*); + src/trainer_pokemon_sprites.o(.text*); + src/lilycove_lady.o(.text*); + src/battle_dome.o(.text*); + src/battle_palace.o(.text*); + src/match_call.o(.text*); + src/menu.o(.text*); + src/battle_factory_screen.o(.text*); + src/apprentice.o(.text*); + src/frontier_util.o(.text*); + src/battle_arena.o(.text*); + src/battle_factory.o(.text*); + src/battle_pike.o(.text*); + src/mossdeep_gym.o(.text*); + src/battle_pyramid.o(.text*); + src/item_menu.o(.text*); + src/list_menu.o(.text*); + src/dynamic_placeholder_text_util.o(.text*); + src/save_location.o(.text*); + src/item_icon.o(.text*); + src/party_menu.o(.text*); + src/battle_tent.o(.text*); + src/unk_text_util_2.o(.text*); + src/multiboot.o(.text*); + src/unk_81BAD84.o(.text*); + src/battle_controller_player_partner.o(.text*); + src/mirage_tower.o(.text*); + src/berry_fix_program.o(.text*); + src/pokemon_summary_screen.o(.text*); + src/unk_pokedex_area_screen_helper.o(.text*); + src/battle_pyramid_bag.o(.text*); + src/pokenav.o(.text*); + src/pokenav_main_menu.o(.text*); + src/pokenav_match_call_ui.o(.text*); + src/pokenav_unk_1.o(.text*); + src/pokenav_unk_2.o(.text*); + asm/pokenav_unk_2.o(.text*); + src/pokenav_unk_3.o(.text*); + src/pokenav_unk_4.o(.text*); + src/pokenav_unk_5.o(.text*); + asm/pokenav_unk_6.o(.text*); + asm/pokenav_unk_7.o(.text*); + asm/pokenav_unk_8.o(.text*); + asm/pokenav_unk_9.o(.text*); + asm/pokenav_unk_10.o(.text*); + src/pokenav_unk_10.o(.text*); + src/pokenav_match_call_data.o(.text*); + src/menu_specialized.o(.text*); + src/ereader_helpers.o(.text*); + src/faraway_island.o(.text*); + src/ereader_screen.o(.text*); + src/trainer_hill.o(.text*); + src/rayquaza_scene.o(.text*); + src/walda_phrase.o(.text*); + src/contest_link_81D9DE4.o(.text*); + src/gym_leader_rematch.o(.text*); + src/unk_transition.o(.text*); + src/international_string_util.o(.text*); } =0 script_data : @@ -346,70 +346,70 @@ SECTIONS { lib_text : ALIGN(4) { - asm/libgcnmultiboot.o(.text); - asm/m4a_1.o(.text); - src/m4a.o(.text); - src/agb_flash.o(.text); - src/agb_flash_1m.o(.text); - src/agb_flash_mx.o(.text); - src/siirtc.o(.text); - src/librfu_stwi.o(.text); - src/librfu_intr.o(.text); - asm/librfu_intr.o(.text); - src/librfu_rfu.o(.text); - asm/librfu.o(.text); - asm/libagbsyscall.o(.text); - *libgcc.a:_call_via_rX.o(.text); - *libgcc.a:_divdi3.o(.text); - *libgcc.a:_divsi3.o(.text); - *libgcc.a:_dvmd_tls.o(.text); - *libgcc.a:_fixunsdfsi.o(.text); - *libgcc.a:_fixunssfsi.o(.text); - *libgcc.a:_modsi3.o(.text); - *libgcc.a:_muldi3.o(.text); - *libgcc.a:_udivdi3.o(.text); - *libgcc.a:_udivsi3.o(.text); - *libgcc.a:_umodsi3.o(.text); - *libgcc.a:dp-bit.o(.text); - *libgcc.a:fp-bit.o(.text); - *libgcc.a:_lshrdi3.o(.text); - *libgcc.a:_negdi2.o(.text); - *libc.a:memcpy.o(.text); - *libc.a:memset.o(.text); - *libc.a:strcmp.o(.text); - *libc.a:strcpy.o(.text); - *libc.a:vfprintf.o(.text); - *libc.a:vsprintf.o(.text); - *libc.a:fvwrite.o(.text); - *libc.a:locale.o(.text); - *libc.a:findfp.o(.text); - *libc.a:fflush.o(.text); - *libc.a:wsetup.o(.text); - *libc.a:mbtowc_r.o(.text); - *libc.a:s_isinf.o(.text); - *libc.a:s_isnan.o(.text); - *libc.a:memchr.o(.text); - *libc.a:strlen.o(.text); - *libc.a:dtoa.o(.text); - *libc.a:memmove.o(.text); - *libc.a:stdio.o(.text); - *libc.a:mprec.o(.text); - *libc.a:mallocr.o(.text); - *libc.a:fwalk.o(.text); - *libc.a:freer.o(.text); - *libc.a:makebuf.o(.text); - *libc.a:readr.o(.text); - *libc.a:writer.o(.text); - *libc.a:lseekr.o(.text); - *libc.a:closer.o(.text); - *libc.a:callocr.o(.text); - *libc.a:sbrkr.o(.text); - *libc.a:mlock.o(.text); - *libc.a:fstatr.o(.text); - *libc.a:libcfunc.o(.text); - *libc.a:syscalls.o(.text); - *libc.a:errno.o(.text); - src/libisagbprn.o(.text); + asm/libgcnmultiboot.o(.text*); + asm/m4a_1.o(.text*); + src/m4a.o(.text*); + src/agb_flash.o(.text*); + src/agb_flash_1m.o(.text*); + src/agb_flash_mx.o(.text*); + src/siirtc.o(.text*); + src/librfu_stwi.o(.text*); + src/librfu_intr.o(.text*); + asm/librfu_intr.o(.text*); + src/librfu_rfu.o(.text*); + asm/librfu.o(.text*); + asm/libagbsyscall.o(.text*); + *libgcc.a:_call_via_rX.o(.text*); + *libgcc.a:_divdi3.o(.text*); + *libgcc.a:_divsi3.o(.text*); + *libgcc.a:_dvmd_tls.o(.text*); + *libgcc.a:_fixunsdfsi.o(.text*); + *libgcc.a:_fixunssfsi.o(.text*); + *libgcc.a:_modsi3.o(.text*); + *libgcc.a:_muldi3.o(.text*); + *libgcc.a:_udivdi3.o(.text*); + *libgcc.a:_udivsi3.o(.text*); + *libgcc.a:_umodsi3.o(.text*); + *libgcc.a:dp-bit.o(.text*); + *libgcc.a:fp-bit.o(.text*); + *libgcc.a:_lshrdi3.o(.text*); + *libgcc.a:_negdi2.o(.text*); + *libc.a:memcpy.o(.text*); + *libc.a:memset.o(.text*); + *libc.a:strcmp.o(.text*); + *libc.a:strcpy.o(.text*); + *libc.a:vfprintf.o(.text*); + *libc.a:vsprintf.o(.text*); + *libc.a:fvwrite.o(.text*); + *libc.a:locale.o(.text*); + *libc.a:findfp.o(.text*); + *libc.a:fflush.o(.text*); + *libc.a:wsetup.o(.text*); + *libc.a:mbtowc_r.o(.text*); + *libc.a:s_isinf.o(.text*); + *libc.a:s_isnan.o(.text*); + *libc.a:memchr.o(.text*); + *libc.a:strlen.o(.text*); + *libc.a:dtoa.o(.text*); + *libc.a:memmove.o(.text*); + *libc.a:stdio.o(.text*); + *libc.a:mprec.o(.text*); + *libc.a:mallocr.o(.text*); + *libc.a:fwalk.o(.text*); + *libc.a:freer.o(.text*); + *libc.a:makebuf.o(.text*); + *libc.a:readr.o(.text*); + *libc.a:writer.o(.text*); + *libc.a:lseekr.o(.text*); + *libc.a:closer.o(.text*); + *libc.a:callocr.o(.text*); + *libc.a:sbrkr.o(.text*); + *libc.a:mlock.o(.text*); + *libc.a:fstatr.o(.text*); + *libc.a:libcfunc.o(.text*); + *libc.a:syscalls.o(.text*); + *libc.a:errno.o(.text*); + src/libisagbprn.o(.text*); } =0 .rodata : diff --git a/src/battle_main.c b/src/battle_main.c index b4c4bdf5c..61b6a5a12 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -72,6 +72,9 @@ extern const u8 *const gBattlescriptsForUsingItem[]; extern const u8 *const gBattlescriptsForSafariActions[]; // this file's functions +#if !defined(NONMATCHING) && MODERN +#define static +#endif static void CB2_InitBattleInternal(void); static void CB2_PreInitMultiBattle(void); static void CB2_PreInitIngamePlayerPartnerBattle(void); diff --git a/src/cable_car.c b/src/cable_car.c index d44c9a241..adeee2647 100644 --- a/src/cable_car.c +++ b/src/cable_car.c @@ -245,7 +245,7 @@ static void CableCarMainCallback_Setup(void) { u16 imebak; u8 i = 0; - int sizeOut = 0; + u32 sizeOut = 0; switch (gMain.state) { diff --git a/src/item.c b/src/item.c index fe8e8eadd..5e505724c 100644 --- a/src/item.c +++ b/src/item.c @@ -18,6 +18,9 @@ extern u16 gUnknown_0203CF30[]; // this file's functions +#if !defined(NONMATCHING) && MODERN +#define static +#endif static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count); static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count); diff --git a/src/item_menu.c b/src/item_menu.c index a8d1d4445..845ffabb6 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -127,7 +127,7 @@ void sub_81ABAE0(void); u8 sub_81AB1F0(u8); void sub_81AC23C(u8); void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu*); -void PrintItemQuantityPlusGFX(u8 rboxId, int item_index_in_pocket, u8 a); +void PrintItemQuantityPlusGFX(u8 rboxId, s32 item_index_in_pocket, u8 a); void ItemMenu_UseOutOfBattle(u8 taskId); void ItemMenu_Toss(u8 taskId); void ItemMenu_Register(u8 taskId); @@ -830,7 +830,7 @@ void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu *unused) } } -void PrintItemQuantityPlusGFX(u8 rboxId, int item_index_in_pocket, u8 a) +void PrintItemQuantityPlusGFX(u8 rboxId, s32 item_index_in_pocket, u8 a) { u16 itemId; u16 itemQuantity; diff --git a/src/party_menu.c b/src/party_menu.c index ad5807ce4..dd0a4dabd 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1820,7 +1820,7 @@ static bool8 AllocPartyMenuBg(void) static bool8 AllocPartyMiscGfx(void) { - int sizeout; + u32 sizeout; switch (gUnknown_0203CEC4->data[0]) { diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 49b171ec0..c5cd71d15 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -464,6 +464,9 @@ EWRAM_DATA static u8 sMovingMonOrigBoxPos = 0; EWRAM_DATA static bool8 sCanOnlyMove = 0; // This file's functions. +#if !defined(NONMATCHING) && MODERN +#define static +#endif static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); static void Cb2_EnterPSS(u8 boxOption); static u8 GetCurrentBoxOption(void); diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 94dab60bb..4422a70e3 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -64,16 +64,16 @@ static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide); static void HideLeftHeaderSprites(bool32 isOnRightSide); static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide); static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide); -static void MoveLeftHeader(struct Sprite *sprite, int startX, int endX, int duration); +static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration); static void SpriteCB_MoveLeftHeader(struct Sprite *sprite); static void InitPokenavMainMenuResources(void); static void InitHoennMapHeaderSprites(void); static void sub_81C7B74(void); -static u32 LoopedTask_ScrollMenuHeaderDown(int a0); -static u32 LoopedTask_ScrollMenuHeaderUp(int a0); +static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0); +static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0); static void sub_81C7BF8(u32 a0); static void SpriteCB_SpinningPokenav(struct Sprite* sprite); -static u32 LoopedTask_InitPokenavMenu(int a0); +static u32 LoopedTask_InitPokenavMenu(s32 a0); const u16 gSpinningPokenavPaletteData[] = INCBIN_U16("graphics/pokenav/icon2.gbapal"); const u32 gSpinningPokenavGfx[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz"); @@ -360,7 +360,7 @@ bool32 WaitForPokenavShutdownFade(void) return TRUE; } -static u32 LoopedTask_InitPokenavMenu(int a0) +static u32 LoopedTask_InitPokenavMenu(s32 a0) { struct PokenavMainMenuResources *structPtr; @@ -440,7 +440,7 @@ bool32 MainMenuLoopedTaskIsBusy(void) return IsLoopedTaskActive(structPtr->currentTaskId); } -static u32 LoopedTask_ScrollMenuHeaderDown(int a0) +static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0) { switch (a0) { @@ -461,7 +461,7 @@ static u32 LoopedTask_ScrollMenuHeaderDown(int a0) } } -static u32 LoopedTask_ScrollMenuHeaderUp(int a0) +static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0) { if (ChangeBgY(0, 384, 2) <= 0) { @@ -637,7 +637,7 @@ _081C7AAE:\n\ .syntax divided"); } -void sub_81C7AC0(int a0) +void sub_81C7AC0(s32 a0) { struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); @@ -708,7 +708,7 @@ static void sub_81C7BF8(u32 windowId) static void InitPokenavMainMenuResources(void) { - int i; + s32 i; u8 spriteId; struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); @@ -758,13 +758,13 @@ void ResumeSpinningPokenavSprite(void) static void InitHoennMapHeaderSprites(void) { - int i, spriteId; + s32 i, spriteId; struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet); AllocSpritePalette(1); AllocSpritePalette(2); - for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) { spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1); structPtr->leftHeaderSprites[i] = &gSprites[spriteId]; @@ -859,10 +859,10 @@ void sub_81C7FC4(u32 arg0, bool32 arg1) void sub_81C7FDC(void) { - int i; + s32 i; struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) { structPtr->leftHeaderSprites[i]->invisible = TRUE; structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE; @@ -881,7 +881,7 @@ bool32 sub_81C8010(void) static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) { - int start, end, i; + s32 start, end, i; struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); if (!isOnRightSide) @@ -889,7 +889,7 @@ static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) else start = 256, end = 160; - for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) { structPtr->leftHeaderSprites[i]->pos1.y = startY; MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); @@ -898,7 +898,7 @@ static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide) static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) { - int start, end, i; + s32 start, end, i; struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); if (!isOnRightSide) @@ -906,7 +906,7 @@ static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) else start = 256, end = 192; - for (i = 0; i < (int)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) { structPtr->submenuLeftHeaderSprites[i]->pos1.y = startY; MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); @@ -915,7 +915,7 @@ static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide) static void HideLeftHeaderSprites(bool32 isOnRightSide) { - int start, end, i; + s32 start, end, i; struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); if (!isOnRightSide) @@ -923,7 +923,7 @@ static void HideLeftHeaderSprites(bool32 isOnRightSide) else start = 192, end = 256; - for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++) { MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12); } @@ -931,7 +931,7 @@ static void HideLeftHeaderSprites(bool32 isOnRightSide) static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide) { - int start, end, i; + s32 start, end, i; struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); if (!isOnRightSide) @@ -939,13 +939,13 @@ static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide) else start = 192, end = 256; - for (i = 0; i < (int)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) + for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++) { MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12); } } -static void MoveLeftHeader(struct Sprite *sprite, int startX, int endX, int duration) +static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration) { sprite->pos1.x = startX; sprite->data[0] = startX * 16; diff --git a/src/pokenav_unk_3.c b/src/pokenav_unk_3.c index 404743345..d7afada49 100755 --- a/src/pokenav_unk_3.c +++ b/src/pokenav_unk_3.c @@ -34,7 +34,7 @@ static u32 sub_81CABFC(struct Pokenav3Struct *); static u32 sub_81CAC04(struct Pokenav3Struct *); static u32 sub_81CACB8(struct Pokenav3Struct *); static u32 sub_81CACF8(struct Pokenav3Struct *); -static u32 sub_81CAD20(int); +static u32 sub_81CAD20(s32); static bool32 sub_81CB1D0(void); extern const u8 gUnknown_08622508[]; @@ -190,7 +190,7 @@ static u32 sub_81CACF8(struct Pokenav3Struct *state) return 0; } -static u32 sub_81CAD20(int taskState) +static u32 sub_81CAD20(s32 taskState) { int i, j; struct Pokenav3Struct *state = GetSubstructPtr(5); diff --git a/src/pokenav_unk_4.c b/src/pokenav_unk_4.c index 6fa76daf2..cd9651580 100755 --- a/src/pokenav_unk_4.c +++ b/src/pokenav_unk_4.c @@ -50,7 +50,7 @@ struct Pokenav4Struct }; static bool32 sub_81CB310(void); -static u32 sub_81CB324(int); +static u32 sub_81CB324(s32); static void sub_81CBBB8(void); static void sub_81CBC1C(void); static void sub_81CC2B4(void); @@ -156,7 +156,7 @@ static bool32 sub_81CB310(void) return IsLoopedTaskActive(state->unk4); } -static u32 sub_81CB324(int taskState) +static u32 sub_81CB324(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -229,7 +229,7 @@ static u32 sub_81CB324(int taskState) } } -u32 sub_81CB510(int taskState) +u32 sub_81CB510(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -266,7 +266,7 @@ u32 sub_81CB510(int taskState) return 4; } -u32 sub_81CB588(int taskState) +u32 sub_81CB588(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -303,7 +303,7 @@ u32 sub_81CB588(int taskState) return 4; } -u32 sub_81CB600(int taskState) +u32 sub_81CB600(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -340,7 +340,7 @@ u32 sub_81CB600(int taskState) return 4; } -u32 sub_81CB678(int taskState) +u32 sub_81CB678(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -377,7 +377,7 @@ u32 sub_81CB678(int taskState) return 4; } -u32 sub_81CB6F0(int taskState) +u32 sub_81CB6F0(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -396,7 +396,7 @@ u32 sub_81CB6F0(int taskState) return 4; } -u32 sub_81CB734(int taskState) +u32 sub_81CB734(s32 taskState) { struct Pokenav4Struct *state; u16 var0; @@ -408,7 +408,7 @@ u32 sub_81CB734(int taskState) return 4; } -u32 sub_81CB75C(int taskState) +u32 sub_81CB75C(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -427,7 +427,7 @@ u32 sub_81CB75C(int taskState) return 4; } -u32 sub_81CB7A0(int taskState) +u32 sub_81CB7A0(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -459,7 +459,7 @@ u32 sub_81CB7A0(int taskState) return 4; } -u32 sub_81CB824(int taskState) +u32 sub_81CB824(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -485,7 +485,7 @@ u32 sub_81CB824(int taskState) return 4; } -u32 sub_81CB888(int taskState) +u32 sub_81CB888(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); u32 result = 0; @@ -549,7 +549,7 @@ u32 sub_81CB888(int taskState) return result; } -u32 sub_81CB93C(int taskState) +u32 sub_81CB93C(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -578,7 +578,7 @@ u32 sub_81CB93C(int taskState) return 4; } -u32 sub_81CB9C8(int taskState) +u32 sub_81CB9C8(s32 taskState) { int index; int var0; @@ -617,7 +617,7 @@ u32 sub_81CB9C8(int taskState) return 4; } -u32 sub_81CBA68(int taskState) +u32 sub_81CBA68(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -643,7 +643,7 @@ u32 sub_81CBA68(int taskState) return 4; } -u32 sub_81CBAD4(int taskState) +u32 sub_81CBAD4(s32 taskState) { int index; int var0; @@ -682,7 +682,7 @@ u32 sub_81CBAD4(int taskState) return 4; } -u32 sub_81CBB74(int taskState) +u32 sub_81CBB74(s32 taskState) { switch (taskState) { diff --git a/src/pokenav_unk_5.c b/src/pokenav_unk_5.c index eccc200d5..5f24fd07f 100755 --- a/src/pokenav_unk_5.c +++ b/src/pokenav_unk_5.c @@ -42,8 +42,8 @@ struct CityZoomPic static u32 sub_81CC568(struct Pokenav5Struct *); static u32 sub_81CC5B4(struct Pokenav5Struct *); static u32 sub_81CC5DC(struct Pokenav5Struct *); -static u32 sub_81CC6F4(int); -static u32 sub_81CCD34(int); +static u32 sub_81CC6F4(s32); +static u32 sub_81CCD34(s32); static bool32 sub_81CC6BC(void); static void sub_81CC9EC(void); static void sub_81CC9C0(void); @@ -202,7 +202,7 @@ static bool8 sub_81CC6D0(void) return gSaveBlock2Ptr->regionMapZoom == 1; } -static u32 sub_81CC6F4(int taskState) +static u32 sub_81CC6F4(s32 taskState) { int var0; struct RegionMap *regionMap; @@ -518,7 +518,7 @@ static bool32 sub_81CCD24(void) return FuncIsActiveLoopedTask(sub_81CCD34); } -static u32 sub_81CCD34(int taskState) +static u32 sub_81CCD34(s32 taskState) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); if (taskState < (int)ARRAY_COUNT(gUnknown_08623118)) diff --git a/src/secret_base.c b/src/secret_base.c index ac35a090a..12cb8cd61 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -71,7 +71,7 @@ static EWRAM_DATA struct SecretBaseRegistryMenu *sRegistryMenu = NULL; static void Task_ShowSecretBaseRegistryMenu(u8 taskId); static void BuildRegistryMenuItems(u8 taskId); -static void RegistryMenu_OnCursorMove(int unused, bool8 flag, struct ListMenu *menu); +static void RegistryMenu_OnCursorMove(s32 unused, bool8 flag, struct ListMenu *menu); static void FinalizeRegistryMenu(u8 taskId); static void AddRegistryMenuScrollArrows(u8 taskId); static void HandleRegistryMenuInput(u8 taskId); @@ -932,7 +932,7 @@ static void BuildRegistryMenuItems(u8 taskId) gMultiuseListMenuTemplate.maxShowed = data[3]; } -static void RegistryMenu_OnCursorMove(int unused, bool8 flag, struct ListMenu *menu) +static void RegistryMenu_OnCursorMove(s32 unused, bool8 flag, struct ListMenu *menu) { if (flag != TRUE) PlaySE(SE_SELECT); diff --git a/src/shop.c b/src/shop.c index 7f1a8f27e..bf15568fb 100755 --- a/src/shop.c +++ b/src/shop.c @@ -87,8 +87,8 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId); static void Task_ReturnToItemListAfterDecorationPurchase(u8 taskId); static void Task_HandleShopMenuBuy(u8 taskId); static void Task_HandleShopMenuSell(u8 taskId); -static void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, struct ListMenu *list); -static void BuyMenuPrintPriceInList(u8 windowId, int item, u8 y); +static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list); +static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y); static const struct YesNoFuncTable sShopPurchaseYesNoFuncs = { @@ -521,7 +521,7 @@ static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *nam menuItem->id = item; } -static void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, struct ListMenu *list) +static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list) { const u8 *description; if (onInit != TRUE) @@ -550,7 +550,7 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, s BuyMenuPrint(2, description, 3, 1, 0, 0); } -static void BuyMenuPrintPriceInList(u8 windowId, int item, u8 y) +static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) { u8 x; diff --git a/src/trade.c b/src/trade.c index f7650ff03..94accc43c 100644 --- a/src/trade.c +++ b/src/trade.c @@ -158,6 +158,9 @@ static EWRAM_DATA struct { /*0xFE*/ u8 unk_FE; } *gUnknown_020322A0 = {NULL}; +#if !defined(NONMATCHING) && MODERN +#define static +#endif static bool32 sub_8077260(void); static void sub_80773D0(void); static void sub_807811C(void); @@ -2779,7 +2782,7 @@ static void sub_8079398(void) } } -static void DisplayMessageAndContinueTask(void) +static void Wait2SecondsAndCreateYesNoMenu(void) { gUnknown_0203229C->unk_A8++; @@ -2918,7 +2921,7 @@ static void sub_80795AC(void) sub_80781C8(); break; case 14: - DisplayMessageAndContinueTask(); + Wait2SecondsAndCreateYesNoMenu(); break; case 15: sub_8079034(); diff --git a/src/tv.c b/src/tv.c index d696e1a21..b4c8463fd 100644 --- a/src/tv.c +++ b/src/tv.c @@ -69,7 +69,9 @@ EWRAM_DATA ALIGNED(4) u8 sTVShowState = 0; EWRAM_DATA u8 sTVSecretBaseSecretsRandomValues[3] = {}; // Static ROM declarations - +#if !defined(NONMATCHING) && MODERN +#define static +#endif void ClearPokemonNews(void); u8 GetTVChannelByShowType(u8 kind); u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void); From 4a239c4604e42c838e0b0b68f7f59eb4562484a2 Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Fri, 19 Jul 2019 20:54:02 -0400 Subject: [PATCH 18/19] Deprecate build_tools.sh --- .travis.yml | 2 +- INSTALL.md | 6 ------ Makefile | 22 +++++++++++++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb03c0600..1ff0ad2c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ matrix: - g++-7 env: _="Build" script: - - ./build_tools.sh g++-7 + - make -j2 tools CXX=g++-7 - make -j2 compare - make -j2 modern after_success: diff --git a/INSTALL.md b/INSTALL.md index df7b28354..a76175862 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -13,12 +13,6 @@ Then get the compiler from https://github.com/pret/agbcc and run the following c ./install.sh PATH_OF_POKEEMERALD_DIRECTORY ``` -Then in the pokeemerald directory, build the tools. - -``` -./build_tools.sh -``` - Finally, build the rom. ``` diff --git a/Makefile b/Makefile index b6b50271b..7ca3b5bac 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,7 @@ JSONPROC := tools/jsonproc/jsonproc$(EXE) # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: -.PHONY: rom clean compare tidy +.PHONY: rom clean compare tidy tools mostlyclean clean-tools C_SRCS := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c) C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS)) @@ -112,15 +112,31 @@ SUBDIRS := $(sort $(dir $(OBJS))) AUTO_GEN_TARGETS := +TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) +TOOLBASE = $(TOOLDIRS:tools/%=%) +TOOLS = $(foreach tool,$(TOOLBASE),tools/%(tool)/$(tool)$(EXE)) + $(shell mkdir -p $(SUBDIRS)) +all: tools rom + +tools: $(TOOLS) + +$(TOOLS): + @$(foreach tooldir,$(TOOLDIRS),$(MAKE) -C $(tooldir);) + rom: $(ROM) # For contributors to make sure a change didn't affect the contents of the ROM. -compare: $(ROM) +compare: all @$(SHA1) rom.sha1 -clean: tidy +clean: mostlyclean clean-tools + +clean-tools: + @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) + +mostlyclean: tidy rm -f sound/direct_sound_samples/*.bin rm -f $(MID_SUBDIR)/*.s find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} + From 6edacdee36d31b2df69559f28a33b8d9e958bf5e Mon Sep 17 00:00:00 2001 From: PikalaxALT <pikalaxalt@gmail.com> Date: Sat, 20 Jul 2019 12:00:45 -0400 Subject: [PATCH 19/19] Pad the GBA using gbafix instead of objcopy --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7ca3b5bac..7868a6e1e 100644 --- a/Makefile +++ b/Makefile @@ -251,6 +251,7 @@ $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) $(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent $(ROM): $(ELF) - $(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@ + $(OBJCOPY) -O binary $< $@ + $(FIX) $@ -p --silent modern: ; @$(MAKE) MODERN=1