From e4362750b6fba1089fa43355e7f32c0eace85219 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Tue, 9 Aug 2022 19:11:19 +0200
Subject: [PATCH] [cctools] removed redundant implementation of
 `get_toc_byte_sex`

---
 cctools/ld/pass1.c | 41 -----------------------------------------
 1 file changed, 41 deletions(-)

diff --git cctools/ld/pass1.c cctools/ld/pass1.c
index 408f766..1d58fcc 100644
--- cctools/ld/pass1.c
+++ cctools/ld/pass1.c
@@ -1752,47 +1752,6 @@ down:
 	}
 }
 
-/*
- * get_toc_byte_sex() guesses the byte sex of the table of contents of the
- * library mapped in at the address, addr, of size, size based on the first
- * object file's bytesex.  If it can't figure it out, because the library has
- * no object file members or is malformed it will return UNKNOWN_BYTE_SEX.
- */
-__private_extern__
-enum byte_sex
-get_toc_byte_sex(
-char *addr,
-uint32_t size)
-{
-     uint32_t magic;
-     uint32_t ar_name_size;
-     struct ar_hdr *ar_hdr;
-     char *p;
-
-	ar_hdr = (struct ar_hdr *)(addr + SARMAG);
-
-	p = addr + SARMAG + sizeof(struct ar_hdr) +
-	    rnd(strtoul(ar_hdr->ar_size, NULL, 10), sizeof(short));
-	while(p + sizeof(struct ar_hdr) + sizeof(uint32_t) < addr + size){
-	    ar_hdr = (struct ar_hdr *)p;
-	    if(strncmp(ar_hdr->ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0)
-		ar_name_size = strtoul(ar_hdr->ar_name + sizeof(AR_EFMT1) - 1,
-				       NULL, 10);
-	    else
-		ar_name_size = 0;
-	    p += sizeof(struct ar_hdr);
-	    memcpy(&magic, p + ar_name_size, sizeof(uint32_t));
-	    if(magic == MH_MAGIC || magic == MH_MAGIC_64)
-		return(get_host_byte_sex());
-	    else if(magic == SWAP_INT(MH_MAGIC) ||
-		    magic == SWAP_INT(MH_MAGIC_64))
-		return(get_host_byte_sex() == BIG_ENDIAN_BYTE_SEX ?
-		       LITTLE_ENDIAN_BYTE_SEX : BIG_ENDIAN_BYTE_SEX);
-	    p += rnd(strtoul(ar_hdr->ar_size, NULL, 10), sizeof(short));
-	}
-	return(UNKNOWN_BYTE_SEX);
-}
-
 /*
  * check_archive_arch() check the archive specified to see if it's architecture
  * does not match that of whats being loaded and if so returns FALSE.  Else it
-- 
2.38.1

