From 26bd949bcd0f414f908444253ead755a35371b01 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 9 Nov 2026 14:30:01 +0700 Subject: [PATCH] hf gp: fix macOS link error, unaligned pointer in packed sAPDU_t The OP card manager SELECT built its sAPDU_t from a static AID, so clang emitted a constant template with an absolute pointer at offset 5 of the PACKED struct. Apple ld rejects it: ld: pointer not aligned in 'l___const.gp_info.op'+0x5 (cmdhfgp.o) Keep the AID on the stack, like the other sAPDU_t users. Co-Authored-By: Claude Opus 5.5 --- client/src/cmdhfgp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhfgp.c b/client/src/cmdhfgp.c index eba8f311c..e034dddd7 100644 --- a/client/src/cmdhfgp.c +++ b/client/src/cmdhfgp.c @@ -660,7 +660,6 @@ static int CmdHFGPAids(const char *Cmd) { // GP ISD, then the OpenPlatform / Visa card manager of older cards static const uint8_t gp_isd_aid[] = {0xA0, 0x00, 0x00, 0x01, 0x51, 0x00, 0x00, 0x00}; -static const uint8_t gp_op_isd_aid[] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00}; // first TLV with tag in buf[0..len), value returned in *val / *vlen static bool gp_tlv_find(const uint8_t *buf, size_t len, tlv_tag_t tag, const uint8_t **val, size_t *vlen) { @@ -988,7 +987,9 @@ int gp_info(Iso7816CommandChannel channel, bool verbose) { } if (sw != ISO7816_OK) { - sAPDU_t op = {0x00, 0xA4, 0x04, 0x00, sizeof(gp_op_isd_aid), (uint8_t *)gp_op_isd_aid}; + // on the stack, a static address in a PACKED sAPDU_t is an unaligned pointer macOS ld rejects + uint8_t op_aid[] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00}; + sAPDU_t op = {0x00, 0xA4, 0x04, 0x00, sizeof(op_aid), op_aid}; res = Iso7816ExchangeEx(channel, false, true, op, true, 0, resp, sizeof(resp), &resp_len, &sw); if (res != PM3_SUCCESS && sw == 0) { PrintAndLogEx(FAILED, "Exchange failed");