Tracing Android NDK's R_ARM_THM_CALL Truncate Problem

lin zuojian manjian2006@gmail.com
Fri Mar 28 13:37:00 GMT 2014


Hi,
    In case google would guide you here,I leave the answer here.It's to
    add an extra option to you linker,--stub-group-size=<the size
    smaller than 4170000>.I can't tell you the exact size,but you can
    narrow it down till you link.DO NOT USE A SMALLER VALUE than
    neccessary,or the binary will have a performance penlty.

sources:
4170000:
elf32-arm.c:elf32_arm_size_stubs :
  if (stub_group_size == 1)
    {
      /* Default values.  */
      /* Thumb branch range is +-4MB has to be used as the default
	 maximum size (a given section can contain both ARM and Thumb
	 code, so the worst case has to be taken into account).

	 This value is 24K less than that, which allows for 2025
	 12-byte stubs.  If we exceed that, then we will fail to link.
	 The user will have to relink with an explicit group size
	 option.  */
      stub_group_size = 4170000;
    }

stub-group-size:
armelf.em:
PARSE_AND_LIST_LONGOPTS='
...
  { "stub-group-size", required_argument, NULL, OPTION_STUBGROUP_SIZE },
and
PARSE_AND_LIST_ARGS_CASES='
...
    case OPTION_STUBGROUP_SIZE:
      {
	const char *end;

        group_size = bfd_scan_vma (optarg, &end, 0);
        if (*end)
	  einfo (_("%P%F: invalid number `%s'\''\n"), optarg);
      }
      break;
You may also check the rest of long options that armelf ld would accept
in PARSE_AND_LIST_LONGOPTS, it's interesting. 
--
Regards
lin zuojian




More information about the Binutils mailing list