elf32-arm.c (214157) | elf32-arm.c (214634) |
---|---|
1/* 32-bit ELF support for ARM | 1/* 32-bit ELF support for ARM |
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | 2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
3 Free Software Foundation, Inc. 4 5 This file is part of BFD, the Binary File Descriptor library. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 20 | 3 Free Software Foundation, Inc. 4 5 This file is part of BFD, the Binary File Descriptor library. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 20 |
21#include "bfd.h" | |
22#include "sysdep.h" | 21#include "sysdep.h" |
22#include "bfd.h" |
|
23#include "libiberty.h" 24#include "libbfd.h" 25#include "elf-bfd.h" 26#include "elf-vxworks.h" 27#include "elf/arm.h" 28 29#ifndef NUM_ELEM 30#define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0])) --- 30 unchanged lines hidden (view full) --- 61 62#define ARM_ELF_ABI_VERSION 0 63#ifdef __FreeBSD__ 64#define ARM_ELF_OS_ABI_VERSION ELFOSABI_FREEBSD 65#else 66#define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM 67#endif 68 | 23#include "libiberty.h" 24#include "libbfd.h" 25#include "elf-bfd.h" 26#include "elf-vxworks.h" 27#include "elf/arm.h" 28 29#ifndef NUM_ELEM 30#define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0])) --- 30 unchanged lines hidden (view full) --- 61 62#define ARM_ELF_ABI_VERSION 0 63#ifdef __FreeBSD__ 64#define ARM_ELF_OS_ABI_VERSION ELFOSABI_FREEBSD 65#else 66#define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM 67#endif 68 |
69static const struct elf_backend_data elf32_arm_vxworks_bed; | 69static struct elf_backend_data elf32_arm_vxworks_bed; |
70 71/* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g. 72 R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO 73 in that slot. */ 74 75static reloc_howto_type elf32_arm_howto_table_1[] = 76{ 77 /* No relocation */ --- 51 unchanged lines hidden (view full) --- 129 bfd_elf_generic_reloc, /* special_function */ 130 "R_ARM_REL32", /* name */ 131 FALSE, /* partial_inplace */ 132 0xffffffff, /* src_mask */ 133 0xffffffff, /* dst_mask */ 134 TRUE), /* pcrel_offset */ 135 136 /* 8 bit absolute - R_ARM_LDR_PC_G0 in AAELF */ | 70 71/* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g. 72 R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO 73 in that slot. */ 74 75static reloc_howto_type elf32_arm_howto_table_1[] = 76{ 77 /* No relocation */ --- 51 unchanged lines hidden (view full) --- 129 bfd_elf_generic_reloc, /* special_function */ 130 "R_ARM_REL32", /* name */ 131 FALSE, /* partial_inplace */ 132 0xffffffff, /* src_mask */ 133 0xffffffff, /* dst_mask */ 134 TRUE), /* pcrel_offset */ 135 136 /* 8 bit absolute - R_ARM_LDR_PC_G0 in AAELF */ |
137 HOWTO (R_ARM_PC13, /* type */ | 137 HOWTO (R_ARM_LDR_PC_G0, /* type */ |
138 0, /* rightshift */ 139 0, /* size (0 = byte, 1 = short, 2 = long) */ | 138 0, /* rightshift */ 139 0, /* size (0 = byte, 1 = short, 2 = long) */ |
140 8, /* bitsize */ 141 FALSE, /* pc_relative */ | 140 32, /* bitsize */ 141 TRUE, /* pc_relative */ |
142 0, /* bitpos */ | 142 0, /* bitpos */ |
143 complain_overflow_bitfield,/* complain_on_overflow */ | 143 complain_overflow_dont,/* complain_on_overflow */ |
144 bfd_elf_generic_reloc, /* special_function */ | 144 bfd_elf_generic_reloc, /* special_function */ |
145 "R_ARM_PC13", /* name */ | 145 "R_ARM_LDR_PC_G0", /* name */ |
146 FALSE, /* partial_inplace */ | 146 FALSE, /* partial_inplace */ |
147 0x000000ff, /* src_mask */ 148 0x000000ff, /* dst_mask */ 149 FALSE), /* pcrel_offset */ | 147 0xffffffff, /* src_mask */ 148 0xffffffff, /* dst_mask */ 149 TRUE), /* pcrel_offset */ |
150 151 /* 16 bit absolute */ 152 HOWTO (R_ARM_ABS16, /* type */ 153 0, /* rightshift */ 154 1, /* size (0 = byte, 1 = short, 2 = long) */ 155 16, /* bitsize */ 156 FALSE, /* pc_relative */ 157 0, /* bitpos */ --- 58 unchanged lines hidden (view full) --- 216 complain_overflow_dont,/* complain_on_overflow */ 217 bfd_elf_generic_reloc, /* special_function */ 218 "R_ARM_SBREL32", /* name */ 219 FALSE, /* partial_inplace */ 220 0xffffffff, /* src_mask */ 221 0xffffffff, /* dst_mask */ 222 FALSE), /* pcrel_offset */ 223 | 150 151 /* 16 bit absolute */ 152 HOWTO (R_ARM_ABS16, /* type */ 153 0, /* rightshift */ 154 1, /* size (0 = byte, 1 = short, 2 = long) */ 155 16, /* bitsize */ 156 FALSE, /* pc_relative */ 157 0, /* bitpos */ --- 58 unchanged lines hidden (view full) --- 216 complain_overflow_dont,/* complain_on_overflow */ 217 bfd_elf_generic_reloc, /* special_function */ 218 "R_ARM_SBREL32", /* name */ 219 FALSE, /* partial_inplace */ 220 0xffffffff, /* src_mask */ 221 0xffffffff, /* dst_mask */ 222 FALSE), /* pcrel_offset */ 223 |
224 /* FIXME: Has two more bits of offset in Thumb32. */ | |
225 HOWTO (R_ARM_THM_CALL, /* type */ 226 1, /* rightshift */ 227 2, /* size (0 = byte, 1 = short, 2 = long) */ | 224 HOWTO (R_ARM_THM_CALL, /* type */ 225 1, /* rightshift */ 226 2, /* size (0 = byte, 1 = short, 2 = long) */ |
228 23, /* bitsize */ | 227 25, /* bitsize */ |
229 TRUE, /* pc_relative */ 230 0, /* bitpos */ 231 complain_overflow_signed,/* complain_on_overflow */ 232 bfd_elf_generic_reloc, /* special_function */ 233 "R_ARM_THM_CALL", /* name */ 234 FALSE, /* partial_inplace */ 235 0x07ff07ff, /* src_mask */ 236 0x07ff07ff, /* dst_mask */ --- 597 unchanged lines hidden (view full) --- 834 address -4095 .. 4095(base) by altering ADDW to SUBW or vice 835 versa. */ 836 HOWTO (R_ARM_THM_ALU_PREL_11_0,/* type */ 837 0, /* rightshift */ 838 2, /* size (0 = byte, 1 = short, 2 = long) */ 839 13, /* bitsize */ 840 TRUE, /* pc_relative */ 841 0, /* bitpos */ | 228 TRUE, /* pc_relative */ 229 0, /* bitpos */ 230 complain_overflow_signed,/* complain_on_overflow */ 231 bfd_elf_generic_reloc, /* special_function */ 232 "R_ARM_THM_CALL", /* name */ 233 FALSE, /* partial_inplace */ 234 0x07ff07ff, /* src_mask */ 235 0x07ff07ff, /* dst_mask */ --- 597 unchanged lines hidden (view full) --- 833 address -4095 .. 4095(base) by altering ADDW to SUBW or vice 834 versa. */ 835 HOWTO (R_ARM_THM_ALU_PREL_11_0,/* type */ 836 0, /* rightshift */ 837 2, /* size (0 = byte, 1 = short, 2 = long) */ 838 13, /* bitsize */ 839 TRUE, /* pc_relative */ 840 0, /* bitpos */ |
842 complain_overflow_signed,/* complain_on_overflow */ | 841 complain_overflow_dont,/* complain_on_overflow */ |
843 bfd_elf_generic_reloc, /* special_function */ 844 "R_ARM_THM_ALU_PREL_11_0",/* name */ 845 FALSE, /* partial_inplace */ | 842 bfd_elf_generic_reloc, /* special_function */ 843 "R_ARM_THM_ALU_PREL_11_0",/* name */ 844 FALSE, /* partial_inplace */ |
846 0x040070ff, /* src_mask */ 847 0x040070ff, /* dst_mask */ | 845 0xffffffff, /* src_mask */ 846 0xffffffff, /* dst_mask */ |
848 TRUE), /* pcrel_offset */ 849 850 HOWTO (R_ARM_THM_PC12, /* type */ 851 0, /* rightshift */ 852 2, /* size (0 = byte, 1 = short, 2 = long) */ 853 13, /* bitsize */ 854 TRUE, /* pc_relative */ 855 0, /* bitpos */ | 847 TRUE), /* pcrel_offset */ 848 849 HOWTO (R_ARM_THM_PC12, /* type */ 850 0, /* rightshift */ 851 2, /* size (0 = byte, 1 = short, 2 = long) */ 852 13, /* bitsize */ 853 TRUE, /* pc_relative */ 854 0, /* bitpos */ |
856 complain_overflow_signed,/* complain_on_overflow */ | 855 complain_overflow_dont,/* complain_on_overflow */ |
857 bfd_elf_generic_reloc, /* special_function */ 858 "R_ARM_THM_PC12", /* name */ 859 FALSE, /* partial_inplace */ | 856 bfd_elf_generic_reloc, /* special_function */ 857 "R_ARM_THM_PC12", /* name */ 858 FALSE, /* partial_inplace */ |
860 0x040070ff, /* src_mask */ 861 0x040070ff, /* dst_mask */ | 859 0xffffffff, /* src_mask */ 860 0xffffffff, /* dst_mask */ |
862 TRUE), /* pcrel_offset */ 863 864 HOWTO (R_ARM_ABS32_NOI, /* type */ 865 0, /* rightshift */ 866 2, /* size (0 = byte, 1 = short, 2 = long) */ 867 32, /* bitsize */ 868 FALSE, /* pc_relative */ 869 0, /* bitpos */ --- 13 unchanged lines hidden (view full) --- 883 0, /* bitpos */ 884 complain_overflow_dont,/* complain_on_overflow */ 885 bfd_elf_generic_reloc, /* special_function */ 886 "R_ARM_REL32_NOI", /* name */ 887 FALSE, /* partial_inplace */ 888 0xffffffff, /* src_mask */ 889 0xffffffff, /* dst_mask */ 890 FALSE), /* pcrel_offset */ | 861 TRUE), /* pcrel_offset */ 862 863 HOWTO (R_ARM_ABS32_NOI, /* type */ 864 0, /* rightshift */ 865 2, /* size (0 = byte, 1 = short, 2 = long) */ 866 32, /* bitsize */ 867 FALSE, /* pc_relative */ 868 0, /* bitpos */ --- 13 unchanged lines hidden (view full) --- 882 0, /* bitpos */ 883 complain_overflow_dont,/* complain_on_overflow */ 884 bfd_elf_generic_reloc, /* special_function */ 885 "R_ARM_REL32_NOI", /* name */ 886 FALSE, /* partial_inplace */ 887 0xffffffff, /* src_mask */ 888 0xffffffff, /* dst_mask */ 889 FALSE), /* pcrel_offset */ |
891}; | |
892 | 890 |
893/* Relocations 57 .. 83 are the "group relocations" which we do not 894 support. */ | 891 /* Group relocations. */ |
895 | 892 |
896static reloc_howto_type elf32_arm_howto_table_2[] = 897{ | 893 HOWTO (R_ARM_ALU_PC_G0_NC, /* type */ 894 0, /* rightshift */ 895 2, /* size (0 = byte, 1 = short, 2 = long) */ 896 32, /* bitsize */ 897 TRUE, /* pc_relative */ 898 0, /* bitpos */ 899 complain_overflow_dont,/* complain_on_overflow */ 900 bfd_elf_generic_reloc, /* special_function */ 901 "R_ARM_ALU_PC_G0_NC", /* name */ 902 FALSE, /* partial_inplace */ 903 0xffffffff, /* src_mask */ 904 0xffffffff, /* dst_mask */ 905 TRUE), /* pcrel_offset */ 906 907 HOWTO (R_ARM_ALU_PC_G0, /* type */ 908 0, /* rightshift */ 909 2, /* size (0 = byte, 1 = short, 2 = long) */ 910 32, /* bitsize */ 911 TRUE, /* pc_relative */ 912 0, /* bitpos */ 913 complain_overflow_dont,/* complain_on_overflow */ 914 bfd_elf_generic_reloc, /* special_function */ 915 "R_ARM_ALU_PC_G0", /* name */ 916 FALSE, /* partial_inplace */ 917 0xffffffff, /* src_mask */ 918 0xffffffff, /* dst_mask */ 919 TRUE), /* pcrel_offset */ 920 921 HOWTO (R_ARM_ALU_PC_G1_NC, /* type */ 922 0, /* rightshift */ 923 2, /* size (0 = byte, 1 = short, 2 = long) */ 924 32, /* bitsize */ 925 TRUE, /* pc_relative */ 926 0, /* bitpos */ 927 complain_overflow_dont,/* complain_on_overflow */ 928 bfd_elf_generic_reloc, /* special_function */ 929 "R_ARM_ALU_PC_G1_NC", /* name */ 930 FALSE, /* partial_inplace */ 931 0xffffffff, /* src_mask */ 932 0xffffffff, /* dst_mask */ 933 TRUE), /* pcrel_offset */ 934 935 HOWTO (R_ARM_ALU_PC_G1, /* type */ 936 0, /* rightshift */ 937 2, /* size (0 = byte, 1 = short, 2 = long) */ 938 32, /* bitsize */ 939 TRUE, /* pc_relative */ 940 0, /* bitpos */ 941 complain_overflow_dont,/* complain_on_overflow */ 942 bfd_elf_generic_reloc, /* special_function */ 943 "R_ARM_ALU_PC_G1", /* name */ 944 FALSE, /* partial_inplace */ 945 0xffffffff, /* src_mask */ 946 0xffffffff, /* dst_mask */ 947 TRUE), /* pcrel_offset */ 948 949 HOWTO (R_ARM_ALU_PC_G2, /* type */ 950 0, /* rightshift */ 951 2, /* size (0 = byte, 1 = short, 2 = long) */ 952 32, /* bitsize */ 953 TRUE, /* pc_relative */ 954 0, /* bitpos */ 955 complain_overflow_dont,/* complain_on_overflow */ 956 bfd_elf_generic_reloc, /* special_function */ 957 "R_ARM_ALU_PC_G2", /* name */ 958 FALSE, /* partial_inplace */ 959 0xffffffff, /* src_mask */ 960 0xffffffff, /* dst_mask */ 961 TRUE), /* pcrel_offset */ 962 963 HOWTO (R_ARM_LDR_PC_G1, /* type */ 964 0, /* rightshift */ 965 2, /* size (0 = byte, 1 = short, 2 = long) */ 966 32, /* bitsize */ 967 TRUE, /* pc_relative */ 968 0, /* bitpos */ 969 complain_overflow_dont,/* complain_on_overflow */ 970 bfd_elf_generic_reloc, /* special_function */ 971 "R_ARM_LDR_PC_G1", /* name */ 972 FALSE, /* partial_inplace */ 973 0xffffffff, /* src_mask */ 974 0xffffffff, /* dst_mask */ 975 TRUE), /* pcrel_offset */ 976 977 HOWTO (R_ARM_LDR_PC_G2, /* type */ 978 0, /* rightshift */ 979 2, /* size (0 = byte, 1 = short, 2 = long) */ 980 32, /* bitsize */ 981 TRUE, /* pc_relative */ 982 0, /* bitpos */ 983 complain_overflow_dont,/* complain_on_overflow */ 984 bfd_elf_generic_reloc, /* special_function */ 985 "R_ARM_LDR_PC_G2", /* name */ 986 FALSE, /* partial_inplace */ 987 0xffffffff, /* src_mask */ 988 0xffffffff, /* dst_mask */ 989 TRUE), /* pcrel_offset */ 990 991 HOWTO (R_ARM_LDRS_PC_G0, /* type */ 992 0, /* rightshift */ 993 2, /* size (0 = byte, 1 = short, 2 = long) */ 994 32, /* bitsize */ 995 TRUE, /* pc_relative */ 996 0, /* bitpos */ 997 complain_overflow_dont,/* complain_on_overflow */ 998 bfd_elf_generic_reloc, /* special_function */ 999 "R_ARM_LDRS_PC_G0", /* name */ 1000 FALSE, /* partial_inplace */ 1001 0xffffffff, /* src_mask */ 1002 0xffffffff, /* dst_mask */ 1003 TRUE), /* pcrel_offset */ 1004 1005 HOWTO (R_ARM_LDRS_PC_G1, /* type */ 1006 0, /* rightshift */ 1007 2, /* size (0 = byte, 1 = short, 2 = long) */ 1008 32, /* bitsize */ 1009 TRUE, /* pc_relative */ 1010 0, /* bitpos */ 1011 complain_overflow_dont,/* complain_on_overflow */ 1012 bfd_elf_generic_reloc, /* special_function */ 1013 "R_ARM_LDRS_PC_G1", /* name */ 1014 FALSE, /* partial_inplace */ 1015 0xffffffff, /* src_mask */ 1016 0xffffffff, /* dst_mask */ 1017 TRUE), /* pcrel_offset */ 1018 1019 HOWTO (R_ARM_LDRS_PC_G2, /* type */ 1020 0, /* rightshift */ 1021 2, /* size (0 = byte, 1 = short, 2 = long) */ 1022 32, /* bitsize */ 1023 TRUE, /* pc_relative */ 1024 0, /* bitpos */ 1025 complain_overflow_dont,/* complain_on_overflow */ 1026 bfd_elf_generic_reloc, /* special_function */ 1027 "R_ARM_LDRS_PC_G2", /* name */ 1028 FALSE, /* partial_inplace */ 1029 0xffffffff, /* src_mask */ 1030 0xffffffff, /* dst_mask */ 1031 TRUE), /* pcrel_offset */ 1032 1033 HOWTO (R_ARM_LDC_PC_G0, /* type */ 1034 0, /* rightshift */ 1035 2, /* size (0 = byte, 1 = short, 2 = long) */ 1036 32, /* bitsize */ 1037 TRUE, /* pc_relative */ 1038 0, /* bitpos */ 1039 complain_overflow_dont,/* complain_on_overflow */ 1040 bfd_elf_generic_reloc, /* special_function */ 1041 "R_ARM_LDC_PC_G0", /* name */ 1042 FALSE, /* partial_inplace */ 1043 0xffffffff, /* src_mask */ 1044 0xffffffff, /* dst_mask */ 1045 TRUE), /* pcrel_offset */ 1046 1047 HOWTO (R_ARM_LDC_PC_G1, /* type */ 1048 0, /* rightshift */ 1049 2, /* size (0 = byte, 1 = short, 2 = long) */ 1050 32, /* bitsize */ 1051 TRUE, /* pc_relative */ 1052 0, /* bitpos */ 1053 complain_overflow_dont,/* complain_on_overflow */ 1054 bfd_elf_generic_reloc, /* special_function */ 1055 "R_ARM_LDC_PC_G1", /* name */ 1056 FALSE, /* partial_inplace */ 1057 0xffffffff, /* src_mask */ 1058 0xffffffff, /* dst_mask */ 1059 TRUE), /* pcrel_offset */ 1060 1061 HOWTO (R_ARM_LDC_PC_G2, /* type */ 1062 0, /* rightshift */ 1063 2, /* size (0 = byte, 1 = short, 2 = long) */ 1064 32, /* bitsize */ 1065 TRUE, /* pc_relative */ 1066 0, /* bitpos */ 1067 complain_overflow_dont,/* complain_on_overflow */ 1068 bfd_elf_generic_reloc, /* special_function */ 1069 "R_ARM_LDC_PC_G2", /* name */ 1070 FALSE, /* partial_inplace */ 1071 0xffffffff, /* src_mask */ 1072 0xffffffff, /* dst_mask */ 1073 TRUE), /* pcrel_offset */ 1074 1075 HOWTO (R_ARM_ALU_SB_G0_NC, /* type */ 1076 0, /* rightshift */ 1077 2, /* size (0 = byte, 1 = short, 2 = long) */ 1078 32, /* bitsize */ 1079 TRUE, /* pc_relative */ 1080 0, /* bitpos */ 1081 complain_overflow_dont,/* complain_on_overflow */ 1082 bfd_elf_generic_reloc, /* special_function */ 1083 "R_ARM_ALU_SB_G0_NC", /* name */ 1084 FALSE, /* partial_inplace */ 1085 0xffffffff, /* src_mask */ 1086 0xffffffff, /* dst_mask */ 1087 TRUE), /* pcrel_offset */ 1088 1089 HOWTO (R_ARM_ALU_SB_G0, /* type */ 1090 0, /* rightshift */ 1091 2, /* size (0 = byte, 1 = short, 2 = long) */ 1092 32, /* bitsize */ 1093 TRUE, /* pc_relative */ 1094 0, /* bitpos */ 1095 complain_overflow_dont,/* complain_on_overflow */ 1096 bfd_elf_generic_reloc, /* special_function */ 1097 "R_ARM_ALU_SB_G0", /* name */ 1098 FALSE, /* partial_inplace */ 1099 0xffffffff, /* src_mask */ 1100 0xffffffff, /* dst_mask */ 1101 TRUE), /* pcrel_offset */ 1102 1103 HOWTO (R_ARM_ALU_SB_G1_NC, /* type */ 1104 0, /* rightshift */ 1105 2, /* size (0 = byte, 1 = short, 2 = long) */ 1106 32, /* bitsize */ 1107 TRUE, /* pc_relative */ 1108 0, /* bitpos */ 1109 complain_overflow_dont,/* complain_on_overflow */ 1110 bfd_elf_generic_reloc, /* special_function */ 1111 "R_ARM_ALU_SB_G1_NC", /* name */ 1112 FALSE, /* partial_inplace */ 1113 0xffffffff, /* src_mask */ 1114 0xffffffff, /* dst_mask */ 1115 TRUE), /* pcrel_offset */ 1116 1117 HOWTO (R_ARM_ALU_SB_G1, /* type */ 1118 0, /* rightshift */ 1119 2, /* size (0 = byte, 1 = short, 2 = long) */ 1120 32, /* bitsize */ 1121 TRUE, /* pc_relative */ 1122 0, /* bitpos */ 1123 complain_overflow_dont,/* complain_on_overflow */ 1124 bfd_elf_generic_reloc, /* special_function */ 1125 "R_ARM_ALU_SB_G1", /* name */ 1126 FALSE, /* partial_inplace */ 1127 0xffffffff, /* src_mask */ 1128 0xffffffff, /* dst_mask */ 1129 TRUE), /* pcrel_offset */ 1130 1131 HOWTO (R_ARM_ALU_SB_G2, /* type */ 1132 0, /* rightshift */ 1133 2, /* size (0 = byte, 1 = short, 2 = long) */ 1134 32, /* bitsize */ 1135 TRUE, /* pc_relative */ 1136 0, /* bitpos */ 1137 complain_overflow_dont,/* complain_on_overflow */ 1138 bfd_elf_generic_reloc, /* special_function */ 1139 "R_ARM_ALU_SB_G2", /* name */ 1140 FALSE, /* partial_inplace */ 1141 0xffffffff, /* src_mask */ 1142 0xffffffff, /* dst_mask */ 1143 TRUE), /* pcrel_offset */ 1144 1145 HOWTO (R_ARM_LDR_SB_G0, /* type */ 1146 0, /* rightshift */ 1147 2, /* size (0 = byte, 1 = short, 2 = long) */ 1148 32, /* bitsize */ 1149 TRUE, /* pc_relative */ 1150 0, /* bitpos */ 1151 complain_overflow_dont,/* complain_on_overflow */ 1152 bfd_elf_generic_reloc, /* special_function */ 1153 "R_ARM_LDR_SB_G0", /* name */ 1154 FALSE, /* partial_inplace */ 1155 0xffffffff, /* src_mask */ 1156 0xffffffff, /* dst_mask */ 1157 TRUE), /* pcrel_offset */ 1158 1159 HOWTO (R_ARM_LDR_SB_G1, /* type */ 1160 0, /* rightshift */ 1161 2, /* size (0 = byte, 1 = short, 2 = long) */ 1162 32, /* bitsize */ 1163 TRUE, /* pc_relative */ 1164 0, /* bitpos */ 1165 complain_overflow_dont,/* complain_on_overflow */ 1166 bfd_elf_generic_reloc, /* special_function */ 1167 "R_ARM_LDR_SB_G1", /* name */ 1168 FALSE, /* partial_inplace */ 1169 0xffffffff, /* src_mask */ 1170 0xffffffff, /* dst_mask */ 1171 TRUE), /* pcrel_offset */ 1172 1173 HOWTO (R_ARM_LDR_SB_G2, /* type */ 1174 0, /* rightshift */ 1175 2, /* size (0 = byte, 1 = short, 2 = long) */ 1176 32, /* bitsize */ 1177 TRUE, /* pc_relative */ 1178 0, /* bitpos */ 1179 complain_overflow_dont,/* complain_on_overflow */ 1180 bfd_elf_generic_reloc, /* special_function */ 1181 "R_ARM_LDR_SB_G2", /* name */ 1182 FALSE, /* partial_inplace */ 1183 0xffffffff, /* src_mask */ 1184 0xffffffff, /* dst_mask */ 1185 TRUE), /* pcrel_offset */ 1186 1187 HOWTO (R_ARM_LDRS_SB_G0, /* type */ 1188 0, /* rightshift */ 1189 2, /* size (0 = byte, 1 = short, 2 = long) */ 1190 32, /* bitsize */ 1191 TRUE, /* pc_relative */ 1192 0, /* bitpos */ 1193 complain_overflow_dont,/* complain_on_overflow */ 1194 bfd_elf_generic_reloc, /* special_function */ 1195 "R_ARM_LDRS_SB_G0", /* name */ 1196 FALSE, /* partial_inplace */ 1197 0xffffffff, /* src_mask */ 1198 0xffffffff, /* dst_mask */ 1199 TRUE), /* pcrel_offset */ 1200 1201 HOWTO (R_ARM_LDRS_SB_G1, /* type */ 1202 0, /* rightshift */ 1203 2, /* size (0 = byte, 1 = short, 2 = long) */ 1204 32, /* bitsize */ 1205 TRUE, /* pc_relative */ 1206 0, /* bitpos */ 1207 complain_overflow_dont,/* complain_on_overflow */ 1208 bfd_elf_generic_reloc, /* special_function */ 1209 "R_ARM_LDRS_SB_G1", /* name */ 1210 FALSE, /* partial_inplace */ 1211 0xffffffff, /* src_mask */ 1212 0xffffffff, /* dst_mask */ 1213 TRUE), /* pcrel_offset */ 1214 1215 HOWTO (R_ARM_LDRS_SB_G2, /* type */ 1216 0, /* rightshift */ 1217 2, /* size (0 = byte, 1 = short, 2 = long) */ 1218 32, /* bitsize */ 1219 TRUE, /* pc_relative */ 1220 0, /* bitpos */ 1221 complain_overflow_dont,/* complain_on_overflow */ 1222 bfd_elf_generic_reloc, /* special_function */ 1223 "R_ARM_LDRS_SB_G2", /* name */ 1224 FALSE, /* partial_inplace */ 1225 0xffffffff, /* src_mask */ 1226 0xffffffff, /* dst_mask */ 1227 TRUE), /* pcrel_offset */ 1228 1229 HOWTO (R_ARM_LDC_SB_G0, /* type */ 1230 0, /* rightshift */ 1231 2, /* size (0 = byte, 1 = short, 2 = long) */ 1232 32, /* bitsize */ 1233 TRUE, /* pc_relative */ 1234 0, /* bitpos */ 1235 complain_overflow_dont,/* complain_on_overflow */ 1236 bfd_elf_generic_reloc, /* special_function */ 1237 "R_ARM_LDC_SB_G0", /* name */ 1238 FALSE, /* partial_inplace */ 1239 0xffffffff, /* src_mask */ 1240 0xffffffff, /* dst_mask */ 1241 TRUE), /* pcrel_offset */ 1242 1243 HOWTO (R_ARM_LDC_SB_G1, /* type */ 1244 0, /* rightshift */ 1245 2, /* size (0 = byte, 1 = short, 2 = long) */ 1246 32, /* bitsize */ 1247 TRUE, /* pc_relative */ 1248 0, /* bitpos */ 1249 complain_overflow_dont,/* complain_on_overflow */ 1250 bfd_elf_generic_reloc, /* special_function */ 1251 "R_ARM_LDC_SB_G1", /* name */ 1252 FALSE, /* partial_inplace */ 1253 0xffffffff, /* src_mask */ 1254 0xffffffff, /* dst_mask */ 1255 TRUE), /* pcrel_offset */ 1256 1257 HOWTO (R_ARM_LDC_SB_G2, /* type */ 1258 0, /* rightshift */ 1259 2, /* size (0 = byte, 1 = short, 2 = long) */ 1260 32, /* bitsize */ 1261 TRUE, /* pc_relative */ 1262 0, /* bitpos */ 1263 complain_overflow_dont,/* complain_on_overflow */ 1264 bfd_elf_generic_reloc, /* special_function */ 1265 "R_ARM_LDC_SB_G2", /* name */ 1266 FALSE, /* partial_inplace */ 1267 0xffffffff, /* src_mask */ 1268 0xffffffff, /* dst_mask */ 1269 TRUE), /* pcrel_offset */ 1270 1271 /* End of group relocations. */ 1272 |
898 HOWTO (R_ARM_MOVW_BREL_NC, /* type */ 899 0, /* rightshift */ 900 2, /* size (0 = byte, 1 = short, 2 = long) */ 901 16, /* bitsize */ 902 FALSE, /* pc_relative */ 903 0, /* bitpos */ 904 complain_overflow_dont,/* complain_on_overflow */ 905 bfd_elf_generic_reloc, /* special_function */ --- 323 unchanged lines hidden (view full) --- 1229}; 1230 1231/* 112-127 private relocations 1232 128 R_ARM_ME_TOO, obsolete 1233 129-255 unallocated in AAELF. 1234 1235 249-255 extended, currently unused, relocations: */ 1236 | 1273 HOWTO (R_ARM_MOVW_BREL_NC, /* type */ 1274 0, /* rightshift */ 1275 2, /* size (0 = byte, 1 = short, 2 = long) */ 1276 16, /* bitsize */ 1277 FALSE, /* pc_relative */ 1278 0, /* bitpos */ 1279 complain_overflow_dont,/* complain_on_overflow */ 1280 bfd_elf_generic_reloc, /* special_function */ --- 323 unchanged lines hidden (view full) --- 1604}; 1605 1606/* 112-127 private relocations 1607 128 R_ARM_ME_TOO, obsolete 1608 129-255 unallocated in AAELF. 1609 1610 249-255 extended, currently unused, relocations: */ 1611 |
1237static reloc_howto_type elf32_arm_howto_table_3[4] = | 1612static reloc_howto_type elf32_arm_howto_table_2[4] = |
1238{ 1239 HOWTO (R_ARM_RREL32, /* type */ 1240 0, /* rightshift */ 1241 0, /* size (0 = byte, 1 = short, 2 = long) */ 1242 0, /* bitsize */ 1243 FALSE, /* pc_relative */ 1244 0, /* bitpos */ 1245 complain_overflow_dont,/* complain_on_overflow */ --- 48 unchanged lines hidden (view full) --- 1294}; 1295 1296static reloc_howto_type * 1297elf32_arm_howto_from_type (unsigned int r_type) 1298{ 1299 if (r_type < NUM_ELEM (elf32_arm_howto_table_1)) 1300 return &elf32_arm_howto_table_1[r_type]; 1301 | 1613{ 1614 HOWTO (R_ARM_RREL32, /* type */ 1615 0, /* rightshift */ 1616 0, /* size (0 = byte, 1 = short, 2 = long) */ 1617 0, /* bitsize */ 1618 FALSE, /* pc_relative */ 1619 0, /* bitpos */ 1620 complain_overflow_dont,/* complain_on_overflow */ --- 48 unchanged lines hidden (view full) --- 1669}; 1670 1671static reloc_howto_type * 1672elf32_arm_howto_from_type (unsigned int r_type) 1673{ 1674 if (r_type < NUM_ELEM (elf32_arm_howto_table_1)) 1675 return &elf32_arm_howto_table_1[r_type]; 1676 |
1302 if (r_type >= R_ARM_MOVW_BREL_NC 1303 && r_type < R_ARM_MOVW_BREL_NC + NUM_ELEM (elf32_arm_howto_table_2)) 1304 return &elf32_arm_howto_table_2[r_type - R_ARM_MOVW_BREL_NC]; 1305 | |
1306 if (r_type >= R_ARM_RREL32 1307 && r_type < R_ARM_RREL32 + NUM_ELEM (elf32_arm_howto_table_2)) | 1677 if (r_type >= R_ARM_RREL32 1678 && r_type < R_ARM_RREL32 + NUM_ELEM (elf32_arm_howto_table_2)) |
1308 return &elf32_arm_howto_table_3[r_type - R_ARM_RREL32]; | 1679 return &elf32_arm_howto_table_2[r_type - R_ARM_RREL32]; |
1309 1310 return NULL; 1311} 1312 1313static void 1314elf32_arm_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * bfd_reloc, 1315 Elf_Internal_Rela * elf_reloc) 1316{ --- 48 unchanged lines hidden (view full) --- 1365 {BFD_RELOC_ARM_TLS_LDM32, R_ARM_TLS_LDM32}, 1366 {BFD_RELOC_ARM_TLS_DTPMOD32, R_ARM_TLS_DTPMOD32}, 1367 {BFD_RELOC_ARM_TLS_DTPOFF32, R_ARM_TLS_DTPOFF32}, 1368 {BFD_RELOC_ARM_TLS_TPOFF32, R_ARM_TLS_TPOFF32}, 1369 {BFD_RELOC_ARM_TLS_IE32, R_ARM_TLS_IE32}, 1370 {BFD_RELOC_ARM_TLS_LE32, R_ARM_TLS_LE32}, 1371 {BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT}, 1372 {BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY}, | 1680 1681 return NULL; 1682} 1683 1684static void 1685elf32_arm_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, arelent * bfd_reloc, 1686 Elf_Internal_Rela * elf_reloc) 1687{ --- 48 unchanged lines hidden (view full) --- 1736 {BFD_RELOC_ARM_TLS_LDM32, R_ARM_TLS_LDM32}, 1737 {BFD_RELOC_ARM_TLS_DTPMOD32, R_ARM_TLS_DTPMOD32}, 1738 {BFD_RELOC_ARM_TLS_DTPOFF32, R_ARM_TLS_DTPOFF32}, 1739 {BFD_RELOC_ARM_TLS_TPOFF32, R_ARM_TLS_TPOFF32}, 1740 {BFD_RELOC_ARM_TLS_IE32, R_ARM_TLS_IE32}, 1741 {BFD_RELOC_ARM_TLS_LE32, R_ARM_TLS_LE32}, 1742 {BFD_RELOC_VTABLE_INHERIT, R_ARM_GNU_VTINHERIT}, 1743 {BFD_RELOC_VTABLE_ENTRY, R_ARM_GNU_VTENTRY}, |
1744 {BFD_RELOC_ARM_MOVW, R_ARM_MOVW_ABS_NC}, 1745 {BFD_RELOC_ARM_MOVT, R_ARM_MOVT_ABS}, 1746 {BFD_RELOC_ARM_MOVW_PCREL, R_ARM_MOVW_PREL_NC}, 1747 {BFD_RELOC_ARM_MOVT_PCREL, R_ARM_MOVT_PREL}, 1748 {BFD_RELOC_ARM_THUMB_MOVW, R_ARM_THM_MOVW_ABS_NC}, 1749 {BFD_RELOC_ARM_THUMB_MOVT, R_ARM_THM_MOVT_ABS}, 1750 {BFD_RELOC_ARM_THUMB_MOVW_PCREL, R_ARM_THM_MOVW_PREL_NC}, 1751 {BFD_RELOC_ARM_THUMB_MOVT_PCREL, R_ARM_THM_MOVT_PREL}, 1752 {BFD_RELOC_ARM_ALU_PC_G0_NC, R_ARM_ALU_PC_G0_NC}, 1753 {BFD_RELOC_ARM_ALU_PC_G0, R_ARM_ALU_PC_G0}, 1754 {BFD_RELOC_ARM_ALU_PC_G1_NC, R_ARM_ALU_PC_G1_NC}, 1755 {BFD_RELOC_ARM_ALU_PC_G1, R_ARM_ALU_PC_G1}, 1756 {BFD_RELOC_ARM_ALU_PC_G2, R_ARM_ALU_PC_G2}, 1757 {BFD_RELOC_ARM_LDR_PC_G0, R_ARM_LDR_PC_G0}, 1758 {BFD_RELOC_ARM_LDR_PC_G1, R_ARM_LDR_PC_G1}, 1759 {BFD_RELOC_ARM_LDR_PC_G2, R_ARM_LDR_PC_G2}, 1760 {BFD_RELOC_ARM_LDRS_PC_G0, R_ARM_LDRS_PC_G0}, 1761 {BFD_RELOC_ARM_LDRS_PC_G1, R_ARM_LDRS_PC_G1}, 1762 {BFD_RELOC_ARM_LDRS_PC_G2, R_ARM_LDRS_PC_G2}, 1763 {BFD_RELOC_ARM_LDC_PC_G0, R_ARM_LDC_PC_G0}, 1764 {BFD_RELOC_ARM_LDC_PC_G1, R_ARM_LDC_PC_G1}, 1765 {BFD_RELOC_ARM_LDC_PC_G2, R_ARM_LDC_PC_G2}, 1766 {BFD_RELOC_ARM_ALU_SB_G0_NC, R_ARM_ALU_SB_G0_NC}, 1767 {BFD_RELOC_ARM_ALU_SB_G0, R_ARM_ALU_SB_G0}, 1768 {BFD_RELOC_ARM_ALU_SB_G1_NC, R_ARM_ALU_SB_G1_NC}, 1769 {BFD_RELOC_ARM_ALU_SB_G1, R_ARM_ALU_SB_G1}, 1770 {BFD_RELOC_ARM_ALU_SB_G2, R_ARM_ALU_SB_G2}, 1771 {BFD_RELOC_ARM_LDR_SB_G0, R_ARM_LDR_SB_G0}, 1772 {BFD_RELOC_ARM_LDR_SB_G1, R_ARM_LDR_SB_G1}, 1773 {BFD_RELOC_ARM_LDR_SB_G2, R_ARM_LDR_SB_G2}, 1774 {BFD_RELOC_ARM_LDRS_SB_G0, R_ARM_LDRS_SB_G0}, 1775 {BFD_RELOC_ARM_LDRS_SB_G1, R_ARM_LDRS_SB_G1}, 1776 {BFD_RELOC_ARM_LDRS_SB_G2, R_ARM_LDRS_SB_G2}, 1777 {BFD_RELOC_ARM_LDC_SB_G0, R_ARM_LDC_SB_G0}, 1778 {BFD_RELOC_ARM_LDC_SB_G1, R_ARM_LDC_SB_G1}, 1779 {BFD_RELOC_ARM_LDC_SB_G2, R_ARM_LDC_SB_G2} |
|
1373 }; 1374 1375static reloc_howto_type * 1376elf32_arm_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, 1377 bfd_reloc_code_real_type code) 1378{ 1379 unsigned int i; 1380 for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++) 1381 if (elf32_arm_reloc_map[i].bfd_reloc_val == code) 1382 return elf32_arm_howto_from_type (elf32_arm_reloc_map[i].elf_reloc_val); 1383 1384 return NULL; 1385} 1386 | 1780 }; 1781 1782static reloc_howto_type * 1783elf32_arm_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, 1784 bfd_reloc_code_real_type code) 1785{ 1786 unsigned int i; 1787 for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++) 1788 if (elf32_arm_reloc_map[i].bfd_reloc_val == code) 1789 return elf32_arm_howto_from_type (elf32_arm_reloc_map[i].elf_reloc_val); 1790 1791 return NULL; 1792} 1793 |
1794static reloc_howto_type * 1795elf32_arm_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, 1796 const char *r_name) 1797{ 1798 unsigned int i; 1799 1800 for (i = 0; 1801 i < (sizeof (elf32_arm_howto_table_1) 1802 / sizeof (elf32_arm_howto_table_1[0])); 1803 i++) 1804 if (elf32_arm_howto_table_1[i].name != NULL 1805 && strcasecmp (elf32_arm_howto_table_1[i].name, r_name) == 0) 1806 return &elf32_arm_howto_table_1[i]; 1807 1808 for (i = 0; 1809 i < (sizeof (elf32_arm_howto_table_2) 1810 / sizeof (elf32_arm_howto_table_2[0])); 1811 i++) 1812 if (elf32_arm_howto_table_2[i].name != NULL 1813 && strcasecmp (elf32_arm_howto_table_2[i].name, r_name) == 0) 1814 return &elf32_arm_howto_table_2[i]; 1815 1816 return NULL; 1817} 1818 |
|
1387/* Support for core dump NOTE sections */ 1388static bfd_boolean 1389elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) 1390{ 1391 int offset; 1392 size_t size; 1393 1394 switch (note->descsz) --- 85 unchanged lines hidden (view full) --- 1480 Given a function name, and its type, the stub can be found. The 1481 name can be changed. The only requirement is the %s be present. */ 1482#define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t" 1483#define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb" 1484 1485#define ARM2THUMB_GLUE_SECTION_NAME ".glue_7" 1486#define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm" 1487 | 1819/* Support for core dump NOTE sections */ 1820static bfd_boolean 1821elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) 1822{ 1823 int offset; 1824 size_t size; 1825 1826 switch (note->descsz) --- 85 unchanged lines hidden (view full) --- 1912 Given a function name, and its type, the stub can be found. The 1913 name can be changed. The only requirement is the %s be present. */ 1914#define THUMB2ARM_GLUE_SECTION_NAME ".glue_7t" 1915#define THUMB2ARM_GLUE_ENTRY_NAME "__%s_from_thumb" 1916 1917#define ARM2THUMB_GLUE_SECTION_NAME ".glue_7" 1918#define ARM2THUMB_GLUE_ENTRY_NAME "__%s_from_arm" 1919 |
1920#define VFP11_ERRATUM_VENEER_SECTION_NAME ".vfp11_veneer" 1921#define VFP11_ERRATUM_VENEER_ENTRY_NAME "__vfp11_veneer_%x" 1922 |
|
1488/* The name of the dynamic interpreter. This is put in the .interp 1489 section. */ 1490#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" 1491 1492#ifdef FOUR_WORD_PLT 1493 1494/* The first entry in a procedure linkage table looks like 1495 this. It is set up so that any shared library function that is --- 96 unchanged lines hidden (view full) --- 1592 1593typedef struct elf32_elf_section_map 1594{ 1595 bfd_vma vma; 1596 char type; 1597} 1598elf32_arm_section_map; 1599 | 1923/* The name of the dynamic interpreter. This is put in the .interp 1924 section. */ 1925#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" 1926 1927#ifdef FOUR_WORD_PLT 1928 1929/* The first entry in a procedure linkage table looks like 1930 this. It is set up so that any shared library function that is --- 96 unchanged lines hidden (view full) --- 2027 2028typedef struct elf32_elf_section_map 2029{ 2030 bfd_vma vma; 2031 char type; 2032} 2033elf32_arm_section_map; 2034 |
2035/* Information about a VFP11 erratum veneer, or a branch to such a veneer. */ 2036 2037typedef enum 2038{ 2039 VFP11_ERRATUM_BRANCH_TO_ARM_VENEER, 2040 VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER, 2041 VFP11_ERRATUM_ARM_VENEER, 2042 VFP11_ERRATUM_THUMB_VENEER 2043} 2044elf32_vfp11_erratum_type; 2045 2046typedef struct elf32_vfp11_erratum_list 2047{ 2048 struct elf32_vfp11_erratum_list *next; 2049 bfd_vma vma; 2050 union 2051 { 2052 struct 2053 { 2054 struct elf32_vfp11_erratum_list *veneer; 2055 unsigned int vfp_insn; 2056 } b; 2057 struct 2058 { 2059 struct elf32_vfp11_erratum_list *branch; 2060 unsigned int id; 2061 } v; 2062 } u; 2063 elf32_vfp11_erratum_type type; 2064} 2065elf32_vfp11_erratum_list; 2066 |
|
1600typedef struct _arm_elf_section_data 1601{ 1602 struct bfd_elf_section_data elf; 1603 unsigned int mapcount; | 2067typedef struct _arm_elf_section_data 2068{ 2069 struct bfd_elf_section_data elf; 2070 unsigned int mapcount; |
2071 unsigned int mapsize; |
|
1604 elf32_arm_section_map *map; | 2072 elf32_arm_section_map *map; |
2073 unsigned int erratumcount; 2074 elf32_vfp11_erratum_list *erratumlist; |
|
1605} 1606_arm_elf_section_data; 1607 1608#define elf32_arm_section_data(sec) \ 1609 ((_arm_elf_section_data *) elf_section_data (sec)) 1610 1611/* The size of the thread control block. */ 1612#define TCB_SIZE 8 1613 | 2075} 2076_arm_elf_section_data; 2077 2078#define elf32_arm_section_data(sec) \ 2079 ((_arm_elf_section_data *) elf_section_data (sec)) 2080 2081/* The size of the thread control block. */ 2082#define TCB_SIZE 8 2083 |
1614#define NUM_KNOWN_ATTRIBUTES 32 1615 1616typedef struct aeabi_attribute 1617{ 1618 int type; 1619 unsigned int i; 1620 char *s; 1621} aeabi_attribute; 1622 1623typedef struct aeabi_attribute_list 1624{ 1625 struct aeabi_attribute_list *next; 1626 int tag; 1627 aeabi_attribute attr; 1628} aeabi_attribute_list; 1629 | |
1630struct elf32_arm_obj_tdata 1631{ 1632 struct elf_obj_tdata root; 1633 1634 /* tls_type for each local got entry. */ 1635 char *local_got_tls_type; 1636 | 2084struct elf32_arm_obj_tdata 2085{ 2086 struct elf_obj_tdata root; 2087 2088 /* tls_type for each local got entry. */ 2089 char *local_got_tls_type; 2090 |
1637 aeabi_attribute known_eabi_attributes[NUM_KNOWN_ATTRIBUTES]; 1638 aeabi_attribute_list *other_eabi_attributes; | 2091 /* Zero to warn when linking objects with incompatible enum sizes. */ 2092 int no_enum_size_warning; |
1639}; 1640 1641#define elf32_arm_tdata(abfd) \ 1642 ((struct elf32_arm_obj_tdata *) (abfd)->tdata.any) 1643 1644#define elf32_arm_local_got_tls_type(abfd) \ 1645 (elf32_arm_tdata (abfd)->local_got_tls_type) 1646 1647static bfd_boolean 1648elf32_arm_mkobject (bfd *abfd) 1649{ | 2093}; 2094 2095#define elf32_arm_tdata(abfd) \ 2096 ((struct elf32_arm_obj_tdata *) (abfd)->tdata.any) 2097 2098#define elf32_arm_local_got_tls_type(abfd) \ 2099 (elf32_arm_tdata (abfd)->local_got_tls_type) 2100 2101static bfd_boolean 2102elf32_arm_mkobject (bfd *abfd) 2103{ |
1650 bfd_size_type amt = sizeof (struct elf32_arm_obj_tdata); 1651 abfd->tdata.any = bfd_zalloc (abfd, amt); | |
1652 if (abfd->tdata.any == NULL) | 2104 if (abfd->tdata.any == NULL) |
1653 return FALSE; 1654 return TRUE; | 2105 { 2106 bfd_size_type amt = sizeof (struct elf32_arm_obj_tdata); 2107 abfd->tdata.any = bfd_zalloc (abfd, amt); 2108 if (abfd->tdata.any == NULL) 2109 return FALSE; 2110 } 2111 return bfd_elf_mkobject (abfd); |
1655} 1656 1657/* The ARM linker needs to keep track of the number of relocs that it 1658 decides to copy in check_relocs for each symbol. This is so that 1659 it can discard PC relative relocs if it doesn't need them when 1660 linking with -Bsymbolic. We store the information in a field 1661 extending the regular ELF linker hash table. */ 1662 --- 30 unchanged lines hidden (view full) --- 1693 recomputing it from the PLT offset. */ 1694 bfd_signed_vma plt_got_offset; 1695 1696#define GOT_UNKNOWN 0 1697#define GOT_NORMAL 1 1698#define GOT_TLS_GD 2 1699#define GOT_TLS_IE 4 1700 unsigned char tls_type; | 2112} 2113 2114/* The ARM linker needs to keep track of the number of relocs that it 2115 decides to copy in check_relocs for each symbol. This is so that 2116 it can discard PC relative relocs if it doesn't need them when 2117 linking with -Bsymbolic. We store the information in a field 2118 extending the regular ELF linker hash table. */ 2119 --- 30 unchanged lines hidden (view full) --- 2150 recomputing it from the PLT offset. */ 2151 bfd_signed_vma plt_got_offset; 2152 2153#define GOT_UNKNOWN 0 2154#define GOT_NORMAL 1 2155#define GOT_TLS_GD 2 2156#define GOT_TLS_IE 4 2157 unsigned char tls_type; |
2158 2159 /* The symbol marking the real symbol location for exported thumb 2160 symbols with Arm stubs. */ 2161 struct elf_link_hash_entry *export_glue; |
|
1701 }; 1702 1703/* Traverse an arm ELF linker hash table. */ 1704#define elf32_arm_link_hash_traverse(table, func, info) \ 1705 (elf_link_hash_traverse \ 1706 (&(table)->root, \ 1707 (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \ 1708 (info))) --- 9 unchanged lines hidden (view full) --- 1718 struct elf_link_hash_table root; 1719 1720 /* The size in bytes of the section containing the Thumb-to-ARM glue. */ 1721 bfd_size_type thumb_glue_size; 1722 1723 /* The size in bytes of the section containing the ARM-to-Thumb glue. */ 1724 bfd_size_type arm_glue_size; 1725 | 2162 }; 2163 2164/* Traverse an arm ELF linker hash table. */ 2165#define elf32_arm_link_hash_traverse(table, func, info) \ 2166 (elf_link_hash_traverse \ 2167 (&(table)->root, \ 2168 (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \ 2169 (info))) --- 9 unchanged lines hidden (view full) --- 2179 struct elf_link_hash_table root; 2180 2181 /* The size in bytes of the section containing the Thumb-to-ARM glue. */ 2182 bfd_size_type thumb_glue_size; 2183 2184 /* The size in bytes of the section containing the ARM-to-Thumb glue. */ 2185 bfd_size_type arm_glue_size; 2186 |
2187 /* The size in bytes of the section containing glue for VFP11 erratum 2188 veneers. */ 2189 bfd_size_type vfp11_erratum_glue_size; 2190 |
|
1726 /* An arbitrary input BFD chosen to hold the glue sections. */ 1727 bfd * bfd_of_glue_owner; 1728 1729 /* Nonzero to output a BE8 image. */ 1730 int byteswap_code; 1731 1732 /* Zero if R_ARM_TARGET1 means R_ARM_ABS32. | 2191 /* An arbitrary input BFD chosen to hold the glue sections. */ 2192 bfd * bfd_of_glue_owner; 2193 2194 /* Nonzero to output a BE8 image. */ 2195 int byteswap_code; 2196 2197 /* Zero if R_ARM_TARGET1 means R_ARM_ABS32. |
1733 Nonzero if R_ARM_TARGET1 means R_ARM_ABS32. */ | 2198 Nonzero if R_ARM_TARGET1 means R_ARM_REL32. */ |
1734 int target1_is_rel; 1735 1736 /* The relocation to use for R_ARM_TARGET2 relocations. */ 1737 int target2_reloc; 1738 1739 /* Nonzero to fix BX instructions for ARMv4 targets. */ 1740 int fix_v4bx; 1741 1742 /* Nonzero if the ARM/Thumb BLX instructions are available for use. */ 1743 int use_blx; 1744 | 2199 int target1_is_rel; 2200 2201 /* The relocation to use for R_ARM_TARGET2 relocations. */ 2202 int target2_reloc; 2203 2204 /* Nonzero to fix BX instructions for ARMv4 targets. */ 2205 int fix_v4bx; 2206 2207 /* Nonzero if the ARM/Thumb BLX instructions are available for use. */ 2208 int use_blx; 2209 |
2210 /* What sort of code sequences we should look for which may trigger the 2211 VFP11 denorm erratum. */ 2212 bfd_arm_vfp11_fix vfp11_fix; 2213 2214 /* Global counter for the number of fixes we have emitted. */ 2215 int num_vfp11_fixes; 2216 2217 /* Nonzero to force PIC branch veneers. */ 2218 int pic_veneer; 2219 |
|
1745 /* The number of bytes in the initial entry in the PLT. */ 1746 bfd_size_type plt_header_size; 1747 1748 /* The number of bytes in the subsequent PLT etries. */ 1749 bfd_size_type plt_entry_size; 1750 1751 /* True if the target system is VxWorks. */ 1752 int vxworks_p; --- 51 unchanged lines hidden (view full) --- 1804 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, 1805 table, string)); 1806 if (ret != NULL) 1807 { 1808 ret->relocs_copied = NULL; 1809 ret->tls_type = GOT_UNKNOWN; 1810 ret->plt_thumb_refcount = 0; 1811 ret->plt_got_offset = -1; | 2220 /* The number of bytes in the initial entry in the PLT. */ 2221 bfd_size_type plt_header_size; 2222 2223 /* The number of bytes in the subsequent PLT etries. */ 2224 bfd_size_type plt_entry_size; 2225 2226 /* True if the target system is VxWorks. */ 2227 int vxworks_p; --- 51 unchanged lines hidden (view full) --- 2279 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, 2280 table, string)); 2281 if (ret != NULL) 2282 { 2283 ret->relocs_copied = NULL; 2284 ret->tls_type = GOT_UNKNOWN; 2285 ret->plt_thumb_refcount = 0; 2286 ret->plt_got_offset = -1; |
2287 ret->export_glue = NULL; |
|
1812 } 1813 1814 return (struct bfd_hash_entry *) ret; 1815} 1816 1817/* Return true if NAME is the name of the relocation section associated 1818 with S. */ 1819 1820static bfd_boolean 1821reloc_section_p (struct elf32_arm_link_hash_table *htab, 1822 const char *name, asection *s) 1823{ 1824 if (htab->use_rel) | 2288 } 2289 2290 return (struct bfd_hash_entry *) ret; 2291} 2292 2293/* Return true if NAME is the name of the relocation section associated 2294 with S. */ 2295 2296static bfd_boolean 2297reloc_section_p (struct elf32_arm_link_hash_table *htab, 2298 const char *name, asection *s) 2299{ 2300 if (htab->use_rel) |
1825 return strncmp (name, ".rel", 4) == 0 && strcmp (s->name, name + 4) == 0; | 2301 return CONST_STRNEQ (name, ".rel") && strcmp (s->name, name + 4) == 0; |
1826 else | 2302 else |
1827 return strncmp (name, ".rela", 5) == 0 && strcmp (s->name, name + 5) == 0; | 2303 return CONST_STRNEQ (name, ".rela") && strcmp (s->name, name + 5) == 0; |
1828} 1829 1830/* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up 1831 shortcuts to them in our hash table. */ 1832 1833static bfd_boolean 1834create_got_section (bfd *dynobj, struct bfd_link_info *info) 1835{ --- 116 unchanged lines hidden (view full) --- 1952 } 1953 *pp = edir->relocs_copied; 1954 } 1955 1956 edir->relocs_copied = eind->relocs_copied; 1957 eind->relocs_copied = NULL; 1958 } 1959 | 2304} 2305 2306/* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up 2307 shortcuts to them in our hash table. */ 2308 2309static bfd_boolean 2310create_got_section (bfd *dynobj, struct bfd_link_info *info) 2311{ --- 116 unchanged lines hidden (view full) --- 2428 } 2429 *pp = edir->relocs_copied; 2430 } 2431 2432 edir->relocs_copied = eind->relocs_copied; 2433 eind->relocs_copied = NULL; 2434 } 2435 |
1960 /* Copy over PLT info. */ 1961 edir->plt_thumb_refcount += eind->plt_thumb_refcount; 1962 eind->plt_thumb_refcount = 0; 1963 1964 if (ind->root.type == bfd_link_hash_indirect 1965 && dir->got.refcount <= 0) | 2436 if (ind->root.type == bfd_link_hash_indirect) |
1966 { | 2437 { |
1967 edir->tls_type = eind->tls_type; 1968 eind->tls_type = GOT_UNKNOWN; | 2438 /* Copy over PLT info. */ 2439 edir->plt_thumb_refcount += eind->plt_thumb_refcount; 2440 eind->plt_thumb_refcount = 0; 2441 2442 if (dir->got.refcount <= 0) 2443 { 2444 edir->tls_type = eind->tls_type; 2445 eind->tls_type = GOT_UNKNOWN; 2446 } |
1969 } 1970 1971 _bfd_elf_link_hash_copy_indirect (info, dir, ind); 1972} 1973 1974/* Create an ARM elf linker hash table. */ 1975 1976static struct bfd_link_hash_table * --- 19 unchanged lines hidden (view full) --- 1996 ret->srelgot = NULL; 1997 ret->splt = NULL; 1998 ret->srelplt = NULL; 1999 ret->sdynbss = NULL; 2000 ret->srelbss = NULL; 2001 ret->srelplt2 = NULL; 2002 ret->thumb_glue_size = 0; 2003 ret->arm_glue_size = 0; | 2447 } 2448 2449 _bfd_elf_link_hash_copy_indirect (info, dir, ind); 2450} 2451 2452/* Create an ARM elf linker hash table. */ 2453 2454static struct bfd_link_hash_table * --- 19 unchanged lines hidden (view full) --- 2474 ret->srelgot = NULL; 2475 ret->splt = NULL; 2476 ret->srelplt = NULL; 2477 ret->sdynbss = NULL; 2478 ret->srelbss = NULL; 2479 ret->srelplt2 = NULL; 2480 ret->thumb_glue_size = 0; 2481 ret->arm_glue_size = 0; |
2482 ret->vfp11_fix = BFD_ARM_VFP11_FIX_NONE; 2483 ret->vfp11_erratum_glue_size = 0; 2484 ret->num_vfp11_fixes = 0; |
|
2004 ret->bfd_of_glue_owner = NULL; 2005 ret->byteswap_code = 0; 2006 ret->target1_is_rel = 0; 2007 ret->target2_reloc = R_ARM_NONE; 2008#ifdef FOUR_WORD_PLT 2009 ret->plt_header_size = 16; 2010 ret->plt_entry_size = 16; 2011#else --- 12 unchanged lines hidden (view full) --- 2024 return &ret->root.root; 2025} 2026 2027/* Locate the Thumb encoded calling stub for NAME. */ 2028 2029static struct elf_link_hash_entry * 2030find_thumb_glue (struct bfd_link_info *link_info, 2031 const char *name, | 2485 ret->bfd_of_glue_owner = NULL; 2486 ret->byteswap_code = 0; 2487 ret->target1_is_rel = 0; 2488 ret->target2_reloc = R_ARM_NONE; 2489#ifdef FOUR_WORD_PLT 2490 ret->plt_header_size = 16; 2491 ret->plt_entry_size = 16; 2492#else --- 12 unchanged lines hidden (view full) --- 2505 return &ret->root.root; 2506} 2507 2508/* Locate the Thumb encoded calling stub for NAME. */ 2509 2510static struct elf_link_hash_entry * 2511find_thumb_glue (struct bfd_link_info *link_info, 2512 const char *name, |
2032 bfd *input_bfd) | 2513 char **error_message) |
2033{ 2034 char *tmp_name; 2035 struct elf_link_hash_entry *hash; 2036 struct elf32_arm_link_hash_table *hash_table; 2037 2038 /* We need a pointer to the armelf specific hash table. */ 2039 hash_table = elf32_arm_hash_table (link_info); 2040 2041 tmp_name = bfd_malloc ((bfd_size_type) strlen (name) 2042 + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1); 2043 2044 BFD_ASSERT (tmp_name); 2045 2046 sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name); 2047 2048 hash = elf_link_hash_lookup 2049 (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); 2050 2051 if (hash == NULL) | 2514{ 2515 char *tmp_name; 2516 struct elf_link_hash_entry *hash; 2517 struct elf32_arm_link_hash_table *hash_table; 2518 2519 /* We need a pointer to the armelf specific hash table. */ 2520 hash_table = elf32_arm_hash_table (link_info); 2521 2522 tmp_name = bfd_malloc ((bfd_size_type) strlen (name) 2523 + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1); 2524 2525 BFD_ASSERT (tmp_name); 2526 2527 sprintf (tmp_name, THUMB2ARM_GLUE_ENTRY_NAME, name); 2528 2529 hash = elf_link_hash_lookup 2530 (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); 2531 2532 if (hash == NULL) |
2052 /* xgettext:c-format */ 2053 (*_bfd_error_handler) (_("%B: unable to find THUMB glue '%s' for `%s'"), 2054 input_bfd, tmp_name, name); | 2533 asprintf (error_message, _("unable to find THUMB glue '%s' for '%s'"), 2534 tmp_name, name); |
2055 2056 free (tmp_name); 2057 2058 return hash; 2059} 2060 2061/* Locate the ARM encoded calling stub for NAME. */ 2062 2063static struct elf_link_hash_entry * 2064find_arm_glue (struct bfd_link_info *link_info, 2065 const char *name, | 2535 2536 free (tmp_name); 2537 2538 return hash; 2539} 2540 2541/* Locate the ARM encoded calling stub for NAME. */ 2542 2543static struct elf_link_hash_entry * 2544find_arm_glue (struct bfd_link_info *link_info, 2545 const char *name, |
2066 bfd *input_bfd) | 2546 char **error_message) |
2067{ 2068 char *tmp_name; 2069 struct elf_link_hash_entry *myh; 2070 struct elf32_arm_link_hash_table *hash_table; 2071 2072 /* We need a pointer to the elfarm specific hash table. */ 2073 hash_table = elf32_arm_hash_table (link_info); 2074 2075 tmp_name = bfd_malloc ((bfd_size_type) strlen (name) 2076 + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1); 2077 2078 BFD_ASSERT (tmp_name); 2079 2080 sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name); 2081 2082 myh = elf_link_hash_lookup 2083 (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); 2084 2085 if (myh == NULL) | 2547{ 2548 char *tmp_name; 2549 struct elf_link_hash_entry *myh; 2550 struct elf32_arm_link_hash_table *hash_table; 2551 2552 /* We need a pointer to the elfarm specific hash table. */ 2553 hash_table = elf32_arm_hash_table (link_info); 2554 2555 tmp_name = bfd_malloc ((bfd_size_type) strlen (name) 2556 + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1); 2557 2558 BFD_ASSERT (tmp_name); 2559 2560 sprintf (tmp_name, ARM2THUMB_GLUE_ENTRY_NAME, name); 2561 2562 myh = elf_link_hash_lookup 2563 (&(hash_table)->root, tmp_name, FALSE, FALSE, TRUE); 2564 2565 if (myh == NULL) |
2086 /* xgettext:c-format */ 2087 (*_bfd_error_handler) (_("%B: unable to find ARM glue '%s' for `%s'"), 2088 input_bfd, tmp_name, name); | 2566 asprintf (error_message, _("unable to find ARM glue '%s' for '%s'"), 2567 tmp_name, name); |
2089 2090 free (tmp_name); 2091 2092 return myh; 2093} 2094 2095/* ARM->Thumb glue (static images): 2096 2097 .arm 2098 __func_from_arm: 2099 ldr r12, __func_addr 2100 bx r12 2101 __func_addr: 2102 .word func @ behave as if you saw a ARM_32 reloc. 2103 | 2568 2569 free (tmp_name); 2570 2571 return myh; 2572} 2573 2574/* ARM->Thumb glue (static images): 2575 2576 .arm 2577 __func_from_arm: 2578 ldr r12, __func_addr 2579 bx r12 2580 __func_addr: 2581 .word func @ behave as if you saw a ARM_32 reloc. 2582 |
2583 (v5t static images) 2584 .arm 2585 __func_from_arm: 2586 ldr pc, __func_addr 2587 __func_addr: 2588 .word func @ behave as if you saw a ARM_32 reloc. 2589 |
|
2104 (relocatable images) 2105 .arm 2106 __func_from_arm: 2107 ldr r12, __func_offset 2108 add r12, r12, pc 2109 bx r12 2110 __func_offset: 2111 .word func - . 2112 */ 2113 2114#define ARM2THUMB_STATIC_GLUE_SIZE 12 2115static const insn32 a2t1_ldr_insn = 0xe59fc000; 2116static const insn32 a2t2_bx_r12_insn = 0xe12fff1c; 2117static const insn32 a2t3_func_addr_insn = 0x00000001; 2118 | 2590 (relocatable images) 2591 .arm 2592 __func_from_arm: 2593 ldr r12, __func_offset 2594 add r12, r12, pc 2595 bx r12 2596 __func_offset: 2597 .word func - . 2598 */ 2599 2600#define ARM2THUMB_STATIC_GLUE_SIZE 12 2601static const insn32 a2t1_ldr_insn = 0xe59fc000; 2602static const insn32 a2t2_bx_r12_insn = 0xe12fff1c; 2603static const insn32 a2t3_func_addr_insn = 0x00000001; 2604 |
2605#define ARM2THUMB_V5_STATIC_GLUE_SIZE 8 2606static const insn32 a2t1v5_ldr_insn = 0xe51ff004; 2607static const insn32 a2t2v5_func_addr_insn = 0x00000001; 2608 |
|
2119#define ARM2THUMB_PIC_GLUE_SIZE 16 2120static const insn32 a2t1p_ldr_insn = 0xe59fc004; 2121static const insn32 a2t2p_add_pc_insn = 0xe08cc00f; 2122static const insn32 a2t3p_bx_r12_insn = 0xe12fff1c; 2123 2124/* Thumb->ARM: Thumb->(non-interworking aware) ARM 2125 2126 .thumb .thumb --- 10 unchanged lines hidden (view full) --- 2137 __func_addr: 2138 .word func */ 2139 2140#define THUMB2ARM_GLUE_SIZE 8 2141static const insn16 t2a1_bx_pc_insn = 0x4778; 2142static const insn16 t2a2_noop_insn = 0x46c0; 2143static const insn32 t2a3_b_insn = 0xea000000; 2144 | 2609#define ARM2THUMB_PIC_GLUE_SIZE 16 2610static const insn32 a2t1p_ldr_insn = 0xe59fc004; 2611static const insn32 a2t2p_add_pc_insn = 0xe08cc00f; 2612static const insn32 a2t3p_bx_r12_insn = 0xe12fff1c; 2613 2614/* Thumb->ARM: Thumb->(non-interworking aware) ARM 2615 2616 .thumb .thumb --- 10 unchanged lines hidden (view full) --- 2627 __func_addr: 2628 .word func */ 2629 2630#define THUMB2ARM_GLUE_SIZE 8 2631static const insn16 t2a1_bx_pc_insn = 0x4778; 2632static const insn16 t2a2_noop_insn = 0x46c0; 2633static const insn32 t2a3_b_insn = 0xea000000; 2634 |
2635#define VFP11_ERRATUM_VENEER_SIZE 8 2636 |
|
2145#ifndef ELFARM_NABI_C_INCLUDED 2146bfd_boolean 2147bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info * info) 2148{ 2149 asection * s; 2150 bfd_byte * foo; 2151 struct elf32_arm_link_hash_table * globals; 2152 --- 7 unchanged lines hidden (view full) --- 2160 2161 s = bfd_get_section_by_name (globals->bfd_of_glue_owner, 2162 ARM2THUMB_GLUE_SECTION_NAME); 2163 2164 BFD_ASSERT (s != NULL); 2165 2166 foo = bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size); 2167 | 2637#ifndef ELFARM_NABI_C_INCLUDED 2638bfd_boolean 2639bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info * info) 2640{ 2641 asection * s; 2642 bfd_byte * foo; 2643 struct elf32_arm_link_hash_table * globals; 2644 --- 7 unchanged lines hidden (view full) --- 2652 2653 s = bfd_get_section_by_name (globals->bfd_of_glue_owner, 2654 ARM2THUMB_GLUE_SECTION_NAME); 2655 2656 BFD_ASSERT (s != NULL); 2657 2658 foo = bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size); 2659 |
2168 s->size = globals->arm_glue_size; | 2660 BFD_ASSERT (s->size == globals->arm_glue_size); |
2169 s->contents = foo; 2170 } 2171 2172 if (globals->thumb_glue_size != 0) 2173 { 2174 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2175 2176 s = bfd_get_section_by_name 2177 (globals->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME); 2178 2179 BFD_ASSERT (s != NULL); 2180 2181 foo = bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size); 2182 | 2661 s->contents = foo; 2662 } 2663 2664 if (globals->thumb_glue_size != 0) 2665 { 2666 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2667 2668 s = bfd_get_section_by_name 2669 (globals->bfd_of_glue_owner, THUMB2ARM_GLUE_SECTION_NAME); 2670 2671 BFD_ASSERT (s != NULL); 2672 2673 foo = bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size); 2674 |
2183 s->size = globals->thumb_glue_size; | 2675 BFD_ASSERT (s->size == globals->thumb_glue_size); |
2184 s->contents = foo; 2185 } | 2676 s->contents = foo; 2677 } |
2678 2679 if (globals->vfp11_erratum_glue_size != 0) 2680 { 2681 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2682 2683 s = bfd_get_section_by_name 2684 (globals->bfd_of_glue_owner, VFP11_ERRATUM_VENEER_SECTION_NAME); 2685 2686 BFD_ASSERT (s != NULL); 2687 2688 foo = bfd_alloc (globals->bfd_of_glue_owner, 2689 globals->vfp11_erratum_glue_size); 2690 2691 BFD_ASSERT (s->size == globals->vfp11_erratum_glue_size); 2692 s->contents = foo; 2693 } |
|
2186 2187 return TRUE; 2188} 2189 | 2694 2695 return TRUE; 2696} 2697 |
2190static void | 2698/* Allocate space and symbols for calling a Thumb function from Arm mode. 2699 returns the symbol identifying teh stub. */ 2700static struct elf_link_hash_entry * |
2191record_arm_to_thumb_glue (struct bfd_link_info * link_info, 2192 struct elf_link_hash_entry * h) 2193{ 2194 const char * name = h->root.root.string; 2195 asection * s; 2196 char * tmp_name; 2197 struct elf_link_hash_entry * myh; 2198 struct bfd_link_hash_entry * bh; 2199 struct elf32_arm_link_hash_table * globals; 2200 bfd_vma val; | 2701record_arm_to_thumb_glue (struct bfd_link_info * link_info, 2702 struct elf_link_hash_entry * h) 2703{ 2704 const char * name = h->root.root.string; 2705 asection * s; 2706 char * tmp_name; 2707 struct elf_link_hash_entry * myh; 2708 struct bfd_link_hash_entry * bh; 2709 struct elf32_arm_link_hash_table * globals; 2710 bfd_vma val; |
2711 bfd_size_type size; |
|
2201 2202 globals = elf32_arm_hash_table (link_info); 2203 2204 BFD_ASSERT (globals != NULL); 2205 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2206 2207 s = bfd_get_section_by_name 2208 (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME); --- 8 unchanged lines hidden (view full) --- 2217 2218 myh = elf_link_hash_lookup 2219 (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); 2220 2221 if (myh != NULL) 2222 { 2223 /* We've already seen this guy. */ 2224 free (tmp_name); | 2712 2713 globals = elf32_arm_hash_table (link_info); 2714 2715 BFD_ASSERT (globals != NULL); 2716 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2717 2718 s = bfd_get_section_by_name 2719 (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME); --- 8 unchanged lines hidden (view full) --- 2728 2729 myh = elf_link_hash_lookup 2730 (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); 2731 2732 if (myh != NULL) 2733 { 2734 /* We've already seen this guy. */ 2735 free (tmp_name); |
2225 return; | 2736 return myh; |
2226 } 2227 2228 /* The only trick here is using hash_table->arm_glue_size as the value. 2229 Even though the section isn't allocated yet, this is where we will be 2230 putting it. */ 2231 bh = NULL; 2232 val = globals->arm_glue_size + 1; 2233 _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner, 2234 tmp_name, BSF_GLOBAL, s, val, 2235 NULL, TRUE, FALSE, &bh); 2236 2237 myh = (struct elf_link_hash_entry *) bh; 2238 myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC); 2239 myh->forced_local = 1; 2240 2241 free (tmp_name); 2242 | 2737 } 2738 2739 /* The only trick here is using hash_table->arm_glue_size as the value. 2740 Even though the section isn't allocated yet, this is where we will be 2741 putting it. */ 2742 bh = NULL; 2743 val = globals->arm_glue_size + 1; 2744 _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner, 2745 tmp_name, BSF_GLOBAL, s, val, 2746 NULL, TRUE, FALSE, &bh); 2747 2748 myh = (struct elf_link_hash_entry *) bh; 2749 myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC); 2750 myh->forced_local = 1; 2751 2752 free (tmp_name); 2753 |
2243 if ((link_info->shared || globals->root.is_relocatable_executable)) 2244 globals->arm_glue_size += ARM2THUMB_PIC_GLUE_SIZE; | 2754 if (link_info->shared || globals->root.is_relocatable_executable 2755 || globals->pic_veneer) 2756 size = ARM2THUMB_PIC_GLUE_SIZE; 2757 else if (globals->use_blx) 2758 size = ARM2THUMB_V5_STATIC_GLUE_SIZE; |
2245 else | 2759 else |
2246 globals->arm_glue_size += ARM2THUMB_STATIC_GLUE_SIZE; | 2760 size = ARM2THUMB_STATIC_GLUE_SIZE; |
2247 | 2761 |
2248 return; | 2762 s->size += size; 2763 globals->arm_glue_size += size; 2764 2765 return myh; |
2249} 2250 2251static void 2252record_thumb_to_arm_glue (struct bfd_link_info *link_info, 2253 struct elf_link_hash_entry *h) 2254{ 2255 const char *name = h->root.root.string; 2256 asection *s; --- 57 unchanged lines hidden (view full) --- 2314 bh = NULL; 2315 val = hash_table->thumb_glue_size + 4, 2316 _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, 2317 tmp_name, BSF_LOCAL, s, val, 2318 NULL, TRUE, FALSE, &bh); 2319 2320 free (tmp_name); 2321 | 2766} 2767 2768static void 2769record_thumb_to_arm_glue (struct bfd_link_info *link_info, 2770 struct elf_link_hash_entry *h) 2771{ 2772 const char *name = h->root.root.string; 2773 asection *s; --- 57 unchanged lines hidden (view full) --- 2831 bh = NULL; 2832 val = hash_table->thumb_glue_size + 4, 2833 _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, 2834 tmp_name, BSF_LOCAL, s, val, 2835 NULL, TRUE, FALSE, &bh); 2836 2837 free (tmp_name); 2838 |
2839 s->size += THUMB2ARM_GLUE_SIZE; |
|
2322 hash_table->thumb_glue_size += THUMB2ARM_GLUE_SIZE; 2323 2324 return; 2325} 2326 | 2840 hash_table->thumb_glue_size += THUMB2ARM_GLUE_SIZE; 2841 2842 return; 2843} 2844 |
2845 2846/* Add an entry to the code/data map for section SEC. */ 2847 2848static void 2849elf32_arm_section_map_add (asection *sec, char type, bfd_vma vma) 2850{ 2851 struct _arm_elf_section_data *sec_data = elf32_arm_section_data (sec); 2852 unsigned int newidx; 2853 2854 if (sec_data->map == NULL) 2855 { 2856 sec_data->map = bfd_malloc (sizeof (elf32_arm_section_map)); 2857 sec_data->mapcount = 0; 2858 sec_data->mapsize = 1; 2859 } 2860 2861 newidx = sec_data->mapcount++; 2862 2863 if (sec_data->mapcount > sec_data->mapsize) 2864 { 2865 sec_data->mapsize *= 2; 2866 sec_data->map = bfd_realloc (sec_data->map, sec_data->mapsize 2867 * sizeof (elf32_arm_section_map)); 2868 } 2869 2870 sec_data->map[newidx].vma = vma; 2871 sec_data->map[newidx].type = type; 2872} 2873 2874 2875/* Record information about a VFP11 denorm-erratum veneer. Only ARM-mode 2876 veneers are handled for now. */ 2877 2878static bfd_vma 2879record_vfp11_erratum_veneer (struct bfd_link_info *link_info, 2880 elf32_vfp11_erratum_list *branch, 2881 bfd *branch_bfd, 2882 asection *branch_sec, 2883 unsigned int offset) 2884{ 2885 asection *s; 2886 struct elf32_arm_link_hash_table *hash_table; 2887 char *tmp_name; 2888 struct elf_link_hash_entry *myh; 2889 struct bfd_link_hash_entry *bh; 2890 bfd_vma val; 2891 struct _arm_elf_section_data *sec_data; 2892 int errcount; 2893 elf32_vfp11_erratum_list *newerr; 2894 2895 hash_table = elf32_arm_hash_table (link_info); 2896 2897 BFD_ASSERT (hash_table != NULL); 2898 BFD_ASSERT (hash_table->bfd_of_glue_owner != NULL); 2899 2900 s = bfd_get_section_by_name 2901 (hash_table->bfd_of_glue_owner, VFP11_ERRATUM_VENEER_SECTION_NAME); 2902 2903 sec_data = elf32_arm_section_data (s); 2904 2905 BFD_ASSERT (s != NULL); 2906 2907 tmp_name = bfd_malloc ((bfd_size_type) strlen 2908 (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10); 2909 2910 BFD_ASSERT (tmp_name); 2911 2912 sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME, 2913 hash_table->num_vfp11_fixes); 2914 2915 myh = elf_link_hash_lookup 2916 (&(hash_table)->root, tmp_name, FALSE, FALSE, FALSE); 2917 2918 BFD_ASSERT (myh == NULL); 2919 2920 bh = NULL; 2921 val = hash_table->vfp11_erratum_glue_size; 2922 _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, 2923 tmp_name, BSF_FUNCTION | BSF_LOCAL, s, val, 2924 NULL, TRUE, FALSE, &bh); 2925 2926 myh = (struct elf_link_hash_entry *) bh; 2927 myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC); 2928 myh->forced_local = 1; 2929 2930 /* Link veneer back to calling location. */ 2931 errcount = ++(sec_data->erratumcount); 2932 newerr = bfd_zmalloc (sizeof (elf32_vfp11_erratum_list)); 2933 2934 newerr->type = VFP11_ERRATUM_ARM_VENEER; 2935 newerr->vma = -1; 2936 newerr->u.v.branch = branch; 2937 newerr->u.v.id = hash_table->num_vfp11_fixes; 2938 branch->u.b.veneer = newerr; 2939 2940 newerr->next = sec_data->erratumlist; 2941 sec_data->erratumlist = newerr; 2942 2943 /* A symbol for the return from the veneer. */ 2944 sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME "_r", 2945 hash_table->num_vfp11_fixes); 2946 2947 myh = elf_link_hash_lookup 2948 (&(hash_table)->root, tmp_name, FALSE, FALSE, FALSE); 2949 2950 if (myh != NULL) 2951 abort (); 2952 2953 bh = NULL; 2954 val = offset + 4; 2955 _bfd_generic_link_add_one_symbol (link_info, branch_bfd, tmp_name, BSF_LOCAL, 2956 branch_sec, val, NULL, TRUE, FALSE, &bh); 2957 2958 myh = (struct elf_link_hash_entry *) bh; 2959 myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC); 2960 myh->forced_local = 1; 2961 2962 free (tmp_name); 2963 2964 /* Generate a mapping symbol for the veneer section, and explicitly add an 2965 entry for that symbol to the code/data map for the section. */ 2966 if (hash_table->vfp11_erratum_glue_size == 0) 2967 { 2968 bh = NULL; 2969 /* FIXME: Creates an ARM symbol. Thumb mode will need attention if it 2970 ever requires this erratum fix. */ 2971 _bfd_generic_link_add_one_symbol (link_info, 2972 hash_table->bfd_of_glue_owner, "$a", 2973 BSF_LOCAL, s, 0, NULL, 2974 TRUE, FALSE, &bh); 2975 2976 myh = (struct elf_link_hash_entry *) bh; 2977 myh->type = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE); 2978 myh->forced_local = 1; 2979 2980 /* The elf32_arm_init_maps function only cares about symbols from input 2981 BFDs. We must make a note of this generated mapping symbol 2982 ourselves so that code byteswapping works properly in 2983 elf32_arm_write_section. */ 2984 elf32_arm_section_map_add (s, 'a', 0); 2985 } 2986 2987 s->size += VFP11_ERRATUM_VENEER_SIZE; 2988 hash_table->vfp11_erratum_glue_size += VFP11_ERRATUM_VENEER_SIZE; 2989 hash_table->num_vfp11_fixes++; 2990 2991 /* The offset of the veneer. */ 2992 return val; 2993} 2994 |
|
2327/* Add the glue sections to ABFD. This function is called from the 2328 linker scripts in ld/emultempl/{armelf}.em. */ 2329 2330bfd_boolean 2331bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd, 2332 struct bfd_link_info *info) 2333{ 2334 flagword flags; --- 6 unchanged lines hidden (view full) --- 2341 2342 sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME); 2343 2344 if (sec == NULL) 2345 { 2346 /* Note: we do not include the flag SEC_LINKER_CREATED, as this 2347 will prevent elf_link_input_bfd() from processing the contents 2348 of this section. */ | 2995/* Add the glue sections to ABFD. This function is called from the 2996 linker scripts in ld/emultempl/{armelf}.em. */ 2997 2998bfd_boolean 2999bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd, 3000 struct bfd_link_info *info) 3001{ 3002 flagword flags; --- 6 unchanged lines hidden (view full) --- 3009 3010 sec = bfd_get_section_by_name (abfd, ARM2THUMB_GLUE_SECTION_NAME); 3011 3012 if (sec == NULL) 3013 { 3014 /* Note: we do not include the flag SEC_LINKER_CREATED, as this 3015 will prevent elf_link_input_bfd() from processing the contents 3016 of this section. */ |
2349 flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; | 3017 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 3018 | SEC_CODE | SEC_READONLY); |
2350 2351 sec = bfd_make_section_with_flags (abfd, 2352 ARM2THUMB_GLUE_SECTION_NAME, 2353 flags); 2354 2355 if (sec == NULL 2356 || !bfd_set_section_alignment (abfd, sec, 2)) 2357 return FALSE; 2358 2359 /* Set the gc mark to prevent the section from being removed by garbage 2360 collection, despite the fact that no relocs refer to this section. */ 2361 sec->gc_mark = 1; 2362 } 2363 2364 sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME); 2365 2366 if (sec == NULL) 2367 { | 3019 3020 sec = bfd_make_section_with_flags (abfd, 3021 ARM2THUMB_GLUE_SECTION_NAME, 3022 flags); 3023 3024 if (sec == NULL 3025 || !bfd_set_section_alignment (abfd, sec, 2)) 3026 return FALSE; 3027 3028 /* Set the gc mark to prevent the section from being removed by garbage 3029 collection, despite the fact that no relocs refer to this section. */ 3030 sec->gc_mark = 1; 3031 } 3032 3033 sec = bfd_get_section_by_name (abfd, THUMB2ARM_GLUE_SECTION_NAME); 3034 3035 if (sec == NULL) 3036 { |
2368 flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 2369 | SEC_CODE | SEC_READONLY; | 3037 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 3038 | SEC_CODE | SEC_READONLY); |
2370 2371 sec = bfd_make_section_with_flags (abfd, 2372 THUMB2ARM_GLUE_SECTION_NAME, 2373 flags); 2374 2375 if (sec == NULL 2376 || !bfd_set_section_alignment (abfd, sec, 2)) 2377 return FALSE; 2378 2379 sec->gc_mark = 1; 2380 } 2381 | 3039 3040 sec = bfd_make_section_with_flags (abfd, 3041 THUMB2ARM_GLUE_SECTION_NAME, 3042 flags); 3043 3044 if (sec == NULL 3045 || !bfd_set_section_alignment (abfd, sec, 2)) 3046 return FALSE; 3047 3048 sec->gc_mark = 1; 3049 } 3050 |
3051 sec = bfd_get_section_by_name (abfd, VFP11_ERRATUM_VENEER_SECTION_NAME); 3052 3053 if (sec == NULL) 3054 { 3055 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 3056 | SEC_CODE | SEC_READONLY); 3057 3058 sec = bfd_make_section_with_flags (abfd, 3059 VFP11_ERRATUM_VENEER_SECTION_NAME, 3060 flags); 3061 3062 if (sec == NULL 3063 || !bfd_set_section_alignment (abfd, sec, 2)) 3064 return FALSE; 3065 3066 sec->gc_mark = 1; 3067 } 3068 |
|
2382 return TRUE; 2383} 2384 2385/* Select a BFD to be used to hold the sections used by the glue code. 2386 This function is called from the linker scripts in ld/emultempl/ 2387 {armelf/pe}.em */ 2388 2389bfd_boolean --- 19 unchanged lines hidden (view full) --- 2409 /* Save the bfd for later use. */ 2410 globals->bfd_of_glue_owner = abfd; 2411 2412 return TRUE; 2413} 2414 2415static void check_use_blx(struct elf32_arm_link_hash_table *globals) 2416{ | 3069 return TRUE; 3070} 3071 3072/* Select a BFD to be used to hold the sections used by the glue code. 3073 This function is called from the linker scripts in ld/emultempl/ 3074 {armelf/pe}.em */ 3075 3076bfd_boolean --- 19 unchanged lines hidden (view full) --- 3096 /* Save the bfd for later use. */ 3097 globals->bfd_of_glue_owner = abfd; 3098 3099 return TRUE; 3100} 3101 3102static void check_use_blx(struct elf32_arm_link_hash_table *globals) 3103{ |
2417 if (elf32_arm_get_eabi_attr_int (globals->obfd, Tag_CPU_arch) > 2) | 3104 if (bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC, 3105 Tag_CPU_arch) > 2) |
2418 globals->use_blx = 1; 2419} 2420 2421bfd_boolean 2422bfd_elf32_arm_process_before_allocation (bfd *abfd, | 3106 globals->use_blx = 1; 3107} 3108 3109bfd_boolean 3110bfd_elf32_arm_process_before_allocation (bfd *abfd, |
2423 struct bfd_link_info *link_info, 2424 int byteswap_code) | 3111 struct bfd_link_info *link_info) |
2425{ 2426 Elf_Internal_Shdr *symtab_hdr; 2427 Elf_Internal_Rela *internal_relocs = NULL; 2428 Elf_Internal_Rela *irel, *irelend; 2429 bfd_byte *contents = NULL; 2430 2431 asection *sec; 2432 struct elf32_arm_link_hash_table *globals; --- 6 unchanged lines hidden (view full) --- 2439 /* Here we have a bfd that is to be included on the link. We have a hook 2440 to do reloc rummaging, before section sizes are nailed down. */ 2441 globals = elf32_arm_hash_table (link_info); 2442 check_use_blx (globals); 2443 2444 BFD_ASSERT (globals != NULL); 2445 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2446 | 3112{ 3113 Elf_Internal_Shdr *symtab_hdr; 3114 Elf_Internal_Rela *internal_relocs = NULL; 3115 Elf_Internal_Rela *irel, *irelend; 3116 bfd_byte *contents = NULL; 3117 3118 asection *sec; 3119 struct elf32_arm_link_hash_table *globals; --- 6 unchanged lines hidden (view full) --- 3126 /* Here we have a bfd that is to be included on the link. We have a hook 3127 to do reloc rummaging, before section sizes are nailed down. */ 3128 globals = elf32_arm_hash_table (link_info); 3129 check_use_blx (globals); 3130 3131 BFD_ASSERT (globals != NULL); 3132 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 3133 |
2447 if (byteswap_code && !bfd_big_endian (abfd)) | 3134 if (globals->byteswap_code && !bfd_big_endian (abfd)) |
2448 { 2449 _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."), 2450 abfd); 2451 return FALSE; 2452 } | 3135 { 3136 _bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."), 3137 abfd); 3138 return FALSE; 3139 } |
2453 globals->byteswap_code = byteswap_code; | |
2454 2455 /* Rummage around all the relocs and map the glue vectors. */ 2456 sec = abfd->sections; 2457 2458 if (sec == NULL) 2459 return TRUE; 2460 2461 for (; sec != NULL; sec = sec->next) 2462 { 2463 if (sec->reloc_count == 0) 2464 continue; 2465 | 3140 3141 /* Rummage around all the relocs and map the glue vectors. */ 3142 sec = abfd->sections; 3143 3144 if (sec == NULL) 3145 return TRUE; 3146 3147 for (; sec != NULL; sec = sec->next) 3148 { 3149 if (sec->reloc_count == 0) 3150 continue; 3151 |
3152 if ((sec->flags & SEC_EXCLUDE) != 0) 3153 continue; 3154 |
|
2466 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; 2467 2468 /* Load the relocs. */ 2469 internal_relocs 2470 = _bfd_elf_link_read_relocs (abfd, sec, (void *) NULL, 2471 (Elf_Internal_Rela *) NULL, FALSE); 2472 2473 if (internal_relocs == NULL) --- 67 unchanged lines hidden (view full) --- 2541 && !(r_type == R_ARM_CALL && globals->use_blx)) 2542 record_arm_to_thumb_glue (link_info, h); 2543 break; 2544 2545 case R_ARM_THM_CALL: 2546 /* This one is a call from thumb code. We look 2547 up the target of the call. If it is not a thumb 2548 target, we insert glue. */ | 3155 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; 3156 3157 /* Load the relocs. */ 3158 internal_relocs 3159 = _bfd_elf_link_read_relocs (abfd, sec, (void *) NULL, 3160 (Elf_Internal_Rela *) NULL, FALSE); 3161 3162 if (internal_relocs == NULL) --- 67 unchanged lines hidden (view full) --- 3230 && !(r_type == R_ARM_CALL && globals->use_blx)) 3231 record_arm_to_thumb_glue (link_info, h); 3232 break; 3233 3234 case R_ARM_THM_CALL: 3235 /* This one is a call from thumb code. We look 3236 up the target of the call. If it is not a thumb 3237 target, we insert glue. */ |
2549 if (ELF_ST_TYPE (h->type) != STT_ARM_TFUNC && !globals->use_blx) | 3238 if (ELF_ST_TYPE (h->type) != STT_ARM_TFUNC && !globals->use_blx 3239 && h->root.type != bfd_link_hash_undefweak) |
2550 record_thumb_to_arm_glue (link_info, h); 2551 break; 2552 2553 default: 2554 abort (); 2555 } 2556 } 2557 --- 18 unchanged lines hidden (view full) --- 2576 && elf_section_data (sec)->relocs != internal_relocs) 2577 free (internal_relocs); 2578 2579 return FALSE; 2580} 2581#endif 2582 2583 | 3240 record_thumb_to_arm_glue (link_info, h); 3241 break; 3242 3243 default: 3244 abort (); 3245 } 3246 } 3247 --- 18 unchanged lines hidden (view full) --- 3266 && elf_section_data (sec)->relocs != internal_relocs) 3267 free (internal_relocs); 3268 3269 return FALSE; 3270} 3271#endif 3272 3273 |
3274/* Initialise maps of ARM/Thumb/data for input BFDs. */ 3275 3276void 3277bfd_elf32_arm_init_maps (bfd *abfd) 3278{ 3279 Elf_Internal_Sym *isymbuf; 3280 Elf_Internal_Shdr *hdr; 3281 unsigned int i, localsyms; 3282 3283 if ((abfd->flags & DYNAMIC) != 0) 3284 return; 3285 3286 hdr = &elf_tdata (abfd)->symtab_hdr; 3287 localsyms = hdr->sh_info; 3288 3289 /* Obtain a buffer full of symbols for this BFD. The hdr->sh_info field 3290 should contain the number of local symbols, which should come before any 3291 global symbols. Mapping symbols are always local. */ 3292 isymbuf = bfd_elf_get_elf_syms (abfd, hdr, localsyms, 0, NULL, NULL, 3293 NULL); 3294 3295 /* No internal symbols read? Skip this BFD. */ 3296 if (isymbuf == NULL) 3297 return; 3298 3299 for (i = 0; i < localsyms; i++) 3300 { 3301 Elf_Internal_Sym *isym = &isymbuf[i]; 3302 asection *sec = bfd_section_from_elf_index (abfd, isym->st_shndx); 3303 const char *name; 3304 3305 if (sec != NULL 3306 && ELF_ST_BIND (isym->st_info) == STB_LOCAL) 3307 { 3308 name = bfd_elf_string_from_elf_section (abfd, 3309 hdr->sh_link, isym->st_name); 3310 3311 if (bfd_is_arm_special_symbol_name (name, 3312 BFD_ARM_SPECIAL_SYM_TYPE_MAP)) 3313 elf32_arm_section_map_add (sec, name[1], isym->st_value); 3314 } 3315 } 3316} 3317 3318 3319void 3320bfd_elf32_arm_set_vfp11_fix (bfd *obfd, struct bfd_link_info *link_info) 3321{ 3322 struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info); 3323 obj_attribute *out_attr = elf_known_obj_attributes_proc (obfd); 3324 3325 /* We assume that ARMv7+ does not need the VFP11 denorm erratum fix. */ 3326 if (out_attr[Tag_CPU_arch].i >= TAG_CPU_ARCH_V7) 3327 { 3328 switch (globals->vfp11_fix) 3329 { 3330 case BFD_ARM_VFP11_FIX_DEFAULT: 3331 case BFD_ARM_VFP11_FIX_NONE: 3332 globals->vfp11_fix = BFD_ARM_VFP11_FIX_NONE; 3333 break; 3334 3335 default: 3336 /* Give a warning, but do as the user requests anyway. */ 3337 (*_bfd_error_handler) (_("%B: warning: selected VFP11 erratum " 3338 "workaround is not necessary for target architecture"), obfd); 3339 } 3340 } 3341 else if (globals->vfp11_fix == BFD_ARM_VFP11_FIX_DEFAULT) 3342 /* For earlier architectures, we might need the workaround, but do not 3343 enable it by default. If users is running with broken hardware, they 3344 must enable the erratum fix explicitly. */ 3345 globals->vfp11_fix = BFD_ARM_VFP11_FIX_NONE; 3346} 3347 3348 3349enum bfd_arm_vfp11_pipe { 3350 VFP11_FMAC, 3351 VFP11_LS, 3352 VFP11_DS, 3353 VFP11_BAD 3354}; 3355 3356/* Return a VFP register number. This is encoded as RX:X for single-precision 3357 registers, or X:RX for double-precision registers, where RX is the group of 3358 four bits in the instruction encoding and X is the single extension bit. 3359 RX and X fields are specified using their lowest (starting) bit. The return 3360 value is: 3361 3362 0...31: single-precision registers s0...s31 3363 32...63: double-precision registers d0...d31. 3364 3365 Although X should be zero for VFP11 (encoding d0...d15 only), we might 3366 encounter VFP3 instructions, so we allow the full range for DP registers. */ 3367 3368static unsigned int 3369bfd_arm_vfp11_regno (unsigned int insn, bfd_boolean is_double, unsigned int rx, 3370 unsigned int x) 3371{ 3372 if (is_double) 3373 return (((insn >> rx) & 0xf) | (((insn >> x) & 1) << 4)) + 32; 3374 else 3375 return (((insn >> rx) & 0xf) << 1) | ((insn >> x) & 1); 3376} 3377 3378/* Set bits in *WMASK according to a register number REG as encoded by 3379 bfd_arm_vfp11_regno(). Ignore d16-d31. */ 3380 3381static void 3382bfd_arm_vfp11_write_mask (unsigned int *wmask, unsigned int reg) 3383{ 3384 if (reg < 32) 3385 *wmask |= 1 << reg; 3386 else if (reg < 48) 3387 *wmask |= 3 << ((reg - 32) * 2); 3388} 3389 3390/* Return TRUE if WMASK overwrites anything in REGS. */ 3391 3392static bfd_boolean 3393bfd_arm_vfp11_antidependency (unsigned int wmask, int *regs, int numregs) 3394{ 3395 int i; 3396 3397 for (i = 0; i < numregs; i++) 3398 { 3399 unsigned int reg = regs[i]; 3400 3401 if (reg < 32 && (wmask & (1 << reg)) != 0) 3402 return TRUE; 3403 3404 reg -= 32; 3405 3406 if (reg >= 16) 3407 continue; 3408 3409 if ((wmask & (3 << (reg * 2))) != 0) 3410 return TRUE; 3411 } 3412 3413 return FALSE; 3414} 3415 3416/* In this function, we're interested in two things: finding input registers 3417 for VFP data-processing instructions, and finding the set of registers which 3418 arbitrary VFP instructions may write to. We use a 32-bit unsigned int to 3419 hold the written set, so FLDM etc. are easy to deal with (we're only 3420 interested in 32 SP registers or 16 dp registers, due to the VFP version 3421 implemented by the chip in question). DP registers are marked by setting 3422 both SP registers in the write mask). */ 3423 3424static enum bfd_arm_vfp11_pipe 3425bfd_arm_vfp11_insn_decode (unsigned int insn, unsigned int *destmask, int *regs, 3426 int *numregs) 3427{ 3428 enum bfd_arm_vfp11_pipe pipe = VFP11_BAD; 3429 bfd_boolean is_double = ((insn & 0xf00) == 0xb00) ? 1 : 0; 3430 3431 if ((insn & 0x0f000e10) == 0x0e000a00) /* A data-processing insn. */ 3432 { 3433 unsigned int pqrs; 3434 unsigned int fd = bfd_arm_vfp11_regno (insn, is_double, 12, 22); 3435 unsigned int fm = bfd_arm_vfp11_regno (insn, is_double, 0, 5); 3436 3437 pqrs = ((insn & 0x00800000) >> 20) 3438 | ((insn & 0x00300000) >> 19) 3439 | ((insn & 0x00000040) >> 6); 3440 3441 switch (pqrs) 3442 { 3443 case 0: /* fmac[sd]. */ 3444 case 1: /* fnmac[sd]. */ 3445 case 2: /* fmsc[sd]. */ 3446 case 3: /* fnmsc[sd]. */ 3447 pipe = VFP11_FMAC; 3448 bfd_arm_vfp11_write_mask (destmask, fd); 3449 regs[0] = fd; 3450 regs[1] = bfd_arm_vfp11_regno (insn, is_double, 16, 7); /* Fn. */ 3451 regs[2] = fm; 3452 *numregs = 3; 3453 break; 3454 3455 case 4: /* fmul[sd]. */ 3456 case 5: /* fnmul[sd]. */ 3457 case 6: /* fadd[sd]. */ 3458 case 7: /* fsub[sd]. */ 3459 pipe = VFP11_FMAC; 3460 goto vfp_binop; 3461 3462 case 8: /* fdiv[sd]. */ 3463 pipe = VFP11_DS; 3464 vfp_binop: 3465 bfd_arm_vfp11_write_mask (destmask, fd); 3466 regs[0] = bfd_arm_vfp11_regno (insn, is_double, 16, 7); /* Fn. */ 3467 regs[1] = fm; 3468 *numregs = 2; 3469 break; 3470 3471 case 15: /* extended opcode. */ 3472 { 3473 unsigned int extn = ((insn >> 15) & 0x1e) 3474 | ((insn >> 7) & 1); 3475 3476 switch (extn) 3477 { 3478 case 0: /* fcpy[sd]. */ 3479 case 1: /* fabs[sd]. */ 3480 case 2: /* fneg[sd]. */ 3481 case 8: /* fcmp[sd]. */ 3482 case 9: /* fcmpe[sd]. */ 3483 case 10: /* fcmpz[sd]. */ 3484 case 11: /* fcmpez[sd]. */ 3485 case 16: /* fuito[sd]. */ 3486 case 17: /* fsito[sd]. */ 3487 case 24: /* ftoui[sd]. */ 3488 case 25: /* ftouiz[sd]. */ 3489 case 26: /* ftosi[sd]. */ 3490 case 27: /* ftosiz[sd]. */ 3491 /* These instructions will not bounce due to underflow. */ 3492 *numregs = 0; 3493 pipe = VFP11_FMAC; 3494 break; 3495 3496 case 3: /* fsqrt[sd]. */ 3497 /* fsqrt cannot underflow, but it can (perhaps) overwrite 3498 registers to cause the erratum in previous instructions. */ 3499 bfd_arm_vfp11_write_mask (destmask, fd); 3500 pipe = VFP11_DS; 3501 break; 3502 3503 case 15: /* fcvt{ds,sd}. */ 3504 { 3505 int rnum = 0; 3506 3507 bfd_arm_vfp11_write_mask (destmask, fd); 3508 3509 /* Only FCVTSD can underflow. */ 3510 if ((insn & 0x100) != 0) 3511 regs[rnum++] = fm; 3512 3513 *numregs = rnum; 3514 3515 pipe = VFP11_FMAC; 3516 } 3517 break; 3518 3519 default: 3520 return VFP11_BAD; 3521 } 3522 } 3523 break; 3524 3525 default: 3526 return VFP11_BAD; 3527 } 3528 } 3529 /* Two-register transfer. */ 3530 else if ((insn & 0x0fe00ed0) == 0x0c400a10) 3531 { 3532 unsigned int fm = bfd_arm_vfp11_regno (insn, is_double, 0, 5); 3533 3534 if ((insn & 0x100000) == 0) 3535 { 3536 if (is_double) 3537 bfd_arm_vfp11_write_mask (destmask, fm); 3538 else 3539 { 3540 bfd_arm_vfp11_write_mask (destmask, fm); 3541 bfd_arm_vfp11_write_mask (destmask, fm + 1); 3542 } 3543 } 3544 3545 pipe = VFP11_LS; 3546 } 3547 else if ((insn & 0x0e100e00) == 0x0c100a00) /* A load insn. */ 3548 { 3549 int fd = bfd_arm_vfp11_regno (insn, is_double, 12, 22); 3550 unsigned int puw = ((insn >> 21) & 0x1) | (((insn >> 23) & 3) << 1); 3551 3552 switch (puw) 3553 { 3554 case 0: /* Two-reg transfer. We should catch these above. */ 3555 abort (); 3556 3557 case 2: /* fldm[sdx]. */ 3558 case 3: 3559 case 5: 3560 { 3561 unsigned int i, offset = insn & 0xff; 3562 3563 if (is_double) 3564 offset >>= 1; 3565 3566 for (i = fd; i < fd + offset; i++) 3567 bfd_arm_vfp11_write_mask (destmask, i); 3568 } 3569 break; 3570 3571 case 4: /* fld[sd]. */ 3572 case 6: 3573 bfd_arm_vfp11_write_mask (destmask, fd); 3574 break; 3575 3576 default: 3577 return VFP11_BAD; 3578 } 3579 3580 pipe = VFP11_LS; 3581 } 3582 /* Single-register transfer. Note L==0. */ 3583 else if ((insn & 0x0f100e10) == 0x0e000a10) 3584 { 3585 unsigned int opcode = (insn >> 21) & 7; 3586 unsigned int fn = bfd_arm_vfp11_regno (insn, is_double, 16, 7); 3587 3588 switch (opcode) 3589 { 3590 case 0: /* fmsr/fmdlr. */ 3591 case 1: /* fmdhr. */ 3592 /* Mark fmdhr and fmdlr as writing to the whole of the DP 3593 destination register. I don't know if this is exactly right, 3594 but it is the conservative choice. */ 3595 bfd_arm_vfp11_write_mask (destmask, fn); 3596 break; 3597 3598 case 7: /* fmxr. */ 3599 break; 3600 } 3601 3602 pipe = VFP11_LS; 3603 } 3604 3605 return pipe; 3606} 3607 3608 3609static int elf32_arm_compare_mapping (const void * a, const void * b); 3610 3611 3612/* Look for potentially-troublesome code sequences which might trigger the 3613 VFP11 denormal/antidependency erratum. See, e.g., the ARM1136 errata sheet 3614 (available from ARM) for details of the erratum. A short version is 3615 described in ld.texinfo. */ 3616 3617bfd_boolean 3618bfd_elf32_arm_vfp11_erratum_scan (bfd *abfd, struct bfd_link_info *link_info) 3619{ 3620 asection *sec; 3621 bfd_byte *contents = NULL; 3622 int state = 0; 3623 int regs[3], numregs = 0; 3624 struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info); 3625 int use_vector = (globals->vfp11_fix == BFD_ARM_VFP11_FIX_VECTOR); 3626 3627 /* We use a simple FSM to match troublesome VFP11 instruction sequences. 3628 The states transition as follows: 3629 3630 0 -> 1 (vector) or 0 -> 2 (scalar) 3631 A VFP FMAC-pipeline instruction has been seen. Fill 3632 regs[0]..regs[numregs-1] with its input operands. Remember this 3633 instruction in 'first_fmac'. 3634 3635 1 -> 2 3636 Any instruction, except for a VFP instruction which overwrites 3637 regs[*]. 3638 3639 1 -> 3 [ -> 0 ] or 3640 2 -> 3 [ -> 0 ] 3641 A VFP instruction has been seen which overwrites any of regs[*]. 3642 We must make a veneer! Reset state to 0 before examining next 3643 instruction. 3644 3645 2 -> 0 3646 If we fail to match anything in state 2, reset to state 0 and reset 3647 the instruction pointer to the instruction after 'first_fmac'. 3648 3649 If the VFP11 vector mode is in use, there must be at least two unrelated 3650 instructions between anti-dependent VFP11 instructions to properly avoid 3651 triggering the erratum, hence the use of the extra state 1. 3652 */ 3653 3654 /* If we are only performing a partial link do not bother 3655 to construct any glue. */ 3656 if (link_info->relocatable) 3657 return TRUE; 3658 3659 /* We should have chosen a fix type by the time we get here. */ 3660 BFD_ASSERT (globals->vfp11_fix != BFD_ARM_VFP11_FIX_DEFAULT); 3661 3662 if (globals->vfp11_fix == BFD_ARM_VFP11_FIX_NONE) 3663 return TRUE; 3664 3665 /* Skip if this bfd does not correspond to an ELF image. */ 3666 if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) 3667 return TRUE; 3668 3669 for (sec = abfd->sections; sec != NULL; sec = sec->next) 3670 { 3671 unsigned int i, span, first_fmac = 0, veneer_of_insn = 0; 3672 struct _arm_elf_section_data *sec_data; 3673 3674 /* If we don't have executable progbits, we're not interested in this 3675 section. Also skip if section is to be excluded. */ 3676 if (elf_section_type (sec) != SHT_PROGBITS 3677 || (elf_section_flags (sec) & SHF_EXECINSTR) == 0 3678 || (sec->flags & SEC_EXCLUDE) != 0 3679 || strcmp (sec->name, VFP11_ERRATUM_VENEER_SECTION_NAME) == 0) 3680 continue; 3681 3682 sec_data = elf32_arm_section_data (sec); 3683 3684 if (sec_data->mapcount == 0) 3685 continue; 3686 3687 if (elf_section_data (sec)->this_hdr.contents != NULL) 3688 contents = elf_section_data (sec)->this_hdr.contents; 3689 else if (! bfd_malloc_and_get_section (abfd, sec, &contents)) 3690 goto error_return; 3691 3692 qsort (sec_data->map, sec_data->mapcount, sizeof (elf32_arm_section_map), 3693 elf32_arm_compare_mapping); 3694 3695 for (span = 0; span < sec_data->mapcount; span++) 3696 { 3697 unsigned int span_start = sec_data->map[span].vma; 3698 unsigned int span_end = (span == sec_data->mapcount - 1) 3699 ? sec->size : sec_data->map[span + 1].vma; 3700 char span_type = sec_data->map[span].type; 3701 3702 /* FIXME: Only ARM mode is supported at present. We may need to 3703 support Thumb-2 mode also at some point. */ 3704 if (span_type != 'a') 3705 continue; 3706 3707 for (i = span_start; i < span_end;) 3708 { 3709 unsigned int next_i = i + 4; 3710 unsigned int insn = bfd_big_endian (abfd) 3711 ? (contents[i] << 24) 3712 | (contents[i + 1] << 16) 3713 | (contents[i + 2] << 8) 3714 | contents[i + 3] 3715 : (contents[i + 3] << 24) 3716 | (contents[i + 2] << 16) 3717 | (contents[i + 1] << 8) 3718 | contents[i]; 3719 unsigned int writemask = 0; 3720 enum bfd_arm_vfp11_pipe pipe; 3721 3722 switch (state) 3723 { 3724 case 0: 3725 pipe = bfd_arm_vfp11_insn_decode (insn, &writemask, regs, 3726 &numregs); 3727 /* I'm assuming the VFP11 erratum can trigger with denorm 3728 operands on either the FMAC or the DS pipeline. This might 3729 lead to slightly overenthusiastic veneer insertion. */ 3730 if (pipe == VFP11_FMAC || pipe == VFP11_DS) 3731 { 3732 state = use_vector ? 1 : 2; 3733 first_fmac = i; 3734 veneer_of_insn = insn; 3735 } 3736 break; 3737 3738 case 1: 3739 { 3740 int other_regs[3], other_numregs; 3741 pipe = bfd_arm_vfp11_insn_decode (insn, &writemask, 3742 other_regs, 3743 &other_numregs); 3744 if (pipe != VFP11_BAD 3745 && bfd_arm_vfp11_antidependency (writemask, regs, 3746 numregs)) 3747 state = 3; 3748 else 3749 state = 2; 3750 } 3751 break; 3752 3753 case 2: 3754 { 3755 int other_regs[3], other_numregs; 3756 pipe = bfd_arm_vfp11_insn_decode (insn, &writemask, 3757 other_regs, 3758 &other_numregs); 3759 if (pipe != VFP11_BAD 3760 && bfd_arm_vfp11_antidependency (writemask, regs, 3761 numregs)) 3762 state = 3; 3763 else 3764 { 3765 state = 0; 3766 next_i = first_fmac + 4; 3767 } 3768 } 3769 break; 3770 3771 case 3: 3772 abort (); /* Should be unreachable. */ 3773 } 3774 3775 if (state == 3) 3776 { 3777 elf32_vfp11_erratum_list *newerr 3778 = bfd_zmalloc (sizeof (elf32_vfp11_erratum_list)); 3779 int errcount; 3780 3781 errcount = ++(elf32_arm_section_data (sec)->erratumcount); 3782 3783 newerr->u.b.vfp_insn = veneer_of_insn; 3784 3785 switch (span_type) 3786 { 3787 case 'a': 3788 newerr->type = VFP11_ERRATUM_BRANCH_TO_ARM_VENEER; 3789 break; 3790 3791 default: 3792 abort (); 3793 } 3794 3795 record_vfp11_erratum_veneer (link_info, newerr, abfd, sec, 3796 first_fmac); 3797 3798 newerr->vma = -1; 3799 3800 newerr->next = sec_data->erratumlist; 3801 sec_data->erratumlist = newerr; 3802 3803 state = 0; 3804 } 3805 3806 i = next_i; 3807 } 3808 } 3809 3810 if (contents != NULL 3811 && elf_section_data (sec)->this_hdr.contents != contents) 3812 free (contents); 3813 contents = NULL; 3814 } 3815 3816 return TRUE; 3817 3818error_return: 3819 if (contents != NULL 3820 && elf_section_data (sec)->this_hdr.contents != contents) 3821 free (contents); 3822 3823 return FALSE; 3824} 3825 3826/* Find virtual-memory addresses for VFP11 erratum veneers and return locations 3827 after sections have been laid out, using specially-named symbols. */ 3828 3829void 3830bfd_elf32_arm_vfp11_fix_veneer_locations (bfd *abfd, 3831 struct bfd_link_info *link_info) 3832{ 3833 asection *sec; 3834 struct elf32_arm_link_hash_table *globals; 3835 char *tmp_name; 3836 3837 if (link_info->relocatable) 3838 return; 3839 3840 /* Skip if this bfd does not correspond to an ELF image. */ 3841 if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) 3842 return; 3843 3844 globals = elf32_arm_hash_table (link_info); 3845 3846 tmp_name = bfd_malloc ((bfd_size_type) strlen 3847 (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10); 3848 3849 for (sec = abfd->sections; sec != NULL; sec = sec->next) 3850 { 3851 struct _arm_elf_section_data *sec_data = elf32_arm_section_data (sec); 3852 elf32_vfp11_erratum_list *errnode = sec_data->erratumlist; 3853 3854 for (; errnode != NULL; errnode = errnode->next) 3855 { 3856 struct elf_link_hash_entry *myh; 3857 bfd_vma vma; 3858 3859 switch (errnode->type) 3860 { 3861 case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER: 3862 case VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER: 3863 /* Find veneer symbol. */ 3864 sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME, 3865 errnode->u.b.veneer->u.v.id); 3866 3867 myh = elf_link_hash_lookup 3868 (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); 3869 3870 if (myh == NULL) 3871 (*_bfd_error_handler) (_("%B: unable to find VFP11 veneer " 3872 "`%s'"), abfd, tmp_name); 3873 3874 vma = myh->root.u.def.section->output_section->vma 3875 + myh->root.u.def.section->output_offset 3876 + myh->root.u.def.value; 3877 3878 errnode->u.b.veneer->vma = vma; 3879 break; 3880 3881 case VFP11_ERRATUM_ARM_VENEER: 3882 case VFP11_ERRATUM_THUMB_VENEER: 3883 /* Find return location. */ 3884 sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME "_r", 3885 errnode->u.v.id); 3886 3887 myh = elf_link_hash_lookup 3888 (&(globals)->root, tmp_name, FALSE, FALSE, TRUE); 3889 3890 if (myh == NULL) 3891 (*_bfd_error_handler) (_("%B: unable to find VFP11 veneer " 3892 "`%s'"), abfd, tmp_name); 3893 3894 vma = myh->root.u.def.section->output_section->vma 3895 + myh->root.u.def.section->output_offset 3896 + myh->root.u.def.value; 3897 3898 errnode->u.v.branch->vma = vma; 3899 break; 3900 3901 default: 3902 abort (); 3903 } 3904 } 3905 } 3906 3907 free (tmp_name); 3908} 3909 3910 |
|
2584/* Set target relocation values needed during linking. */ 2585 2586void | 3911/* Set target relocation values needed during linking. */ 3912 3913void |
2587bfd_elf32_arm_set_target_relocs (struct bfd_link_info *link_info, | 3914bfd_elf32_arm_set_target_relocs (struct bfd *output_bfd, 3915 struct bfd_link_info *link_info, |
2588 int target1_is_rel, 2589 char * target2_type, 2590 int fix_v4bx, | 3916 int target1_is_rel, 3917 char * target2_type, 3918 int fix_v4bx, |
2591 int use_blx) | 3919 int use_blx, 3920 bfd_arm_vfp11_fix vfp11_fix, 3921 int no_enum_warn, int pic_veneer) |
2592{ 2593 struct elf32_arm_link_hash_table *globals; 2594 2595 globals = elf32_arm_hash_table (link_info); 2596 2597 globals->target1_is_rel = target1_is_rel; 2598 if (strcmp (target2_type, "rel") == 0) 2599 globals->target2_reloc = R_ARM_REL32; 2600 else if (strcmp (target2_type, "abs") == 0) 2601 globals->target2_reloc = R_ARM_ABS32; 2602 else if (strcmp (target2_type, "got-rel") == 0) 2603 globals->target2_reloc = R_ARM_GOT_PREL; 2604 else 2605 { 2606 _bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."), 2607 target2_type); 2608 } 2609 globals->fix_v4bx = fix_v4bx; 2610 globals->use_blx |= use_blx; | 3922{ 3923 struct elf32_arm_link_hash_table *globals; 3924 3925 globals = elf32_arm_hash_table (link_info); 3926 3927 globals->target1_is_rel = target1_is_rel; 3928 if (strcmp (target2_type, "rel") == 0) 3929 globals->target2_reloc = R_ARM_REL32; 3930 else if (strcmp (target2_type, "abs") == 0) 3931 globals->target2_reloc = R_ARM_ABS32; 3932 else if (strcmp (target2_type, "got-rel") == 0) 3933 globals->target2_reloc = R_ARM_GOT_PREL; 3934 else 3935 { 3936 _bfd_error_handler (_("Invalid TARGET2 relocation type '%s'."), 3937 target2_type); 3938 } 3939 globals->fix_v4bx = fix_v4bx; 3940 globals->use_blx |= use_blx; |
3941 globals->vfp11_fix = vfp11_fix; 3942 globals->pic_veneer = pic_veneer; 3943 3944 elf32_arm_tdata (output_bfd)->no_enum_size_warning = no_enum_warn; |
|
2611} 2612 2613/* The thumb form of a long branch is a bit finicky, because the offset 2614 encoding is split over two fields, each in it's own instruction. They 2615 can occur in any order. So given a thumb form of long branch, and an 2616 offset, insert the offset into the thumb branch and return finished 2617 instruction. 2618 --- 40 unchanged lines hidden (view full) --- 2659 br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits; 2660 else 2661 /* FIXME: abort is probably not the right call. krk@cygnus.com */ 2662 abort (); /* Error - not a valid branch instruction form. */ 2663 2664 return br_insn; 2665} 2666 | 3945} 3946 3947/* The thumb form of a long branch is a bit finicky, because the offset 3948 encoding is split over two fields, each in it's own instruction. They 3949 can occur in any order. So given a thumb form of long branch, and an 3950 offset, insert the offset into the thumb branch and return finished 3951 instruction. 3952 --- 40 unchanged lines hidden (view full) --- 3993 br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits; 3994 else 3995 /* FIXME: abort is probably not the right call. krk@cygnus.com */ 3996 abort (); /* Error - not a valid branch instruction form. */ 3997 3998 return br_insn; 3999} 4000 |
4001 4002/* Store an Arm insn into an output section not processed by 4003 elf32_arm_write_section. */ 4004 4005static void 4006put_arm_insn (struct elf32_arm_link_hash_table *htab, 4007 bfd * output_bfd, bfd_vma val, void * ptr) 4008{ 4009 if (htab->byteswap_code != bfd_little_endian (output_bfd)) 4010 bfd_putl32 (val, ptr); 4011 else 4012 bfd_putb32 (val, ptr); 4013} 4014 4015 4016/* Store a 16-bit Thumb insn into an output section not processed by 4017 elf32_arm_write_section. */ 4018 4019static void 4020put_thumb_insn (struct elf32_arm_link_hash_table *htab, 4021 bfd * output_bfd, bfd_vma val, void * ptr) 4022{ 4023 if (htab->byteswap_code != bfd_little_endian (output_bfd)) 4024 bfd_putl16 (val, ptr); 4025 else 4026 bfd_putb16 (val, ptr); 4027} 4028 4029 |
|
2667/* Thumb code calling an ARM function. */ 2668 2669static int 2670elf32_thumb_to_arm_stub (struct bfd_link_info * info, 2671 const char * name, 2672 bfd * input_bfd, 2673 bfd * output_bfd, 2674 asection * input_section, 2675 bfd_byte * hit_data, 2676 asection * sym_sec, 2677 bfd_vma offset, 2678 bfd_signed_vma addend, | 4030/* Thumb code calling an ARM function. */ 4031 4032static int 4033elf32_thumb_to_arm_stub (struct bfd_link_info * info, 4034 const char * name, 4035 bfd * input_bfd, 4036 bfd * output_bfd, 4037 asection * input_section, 4038 bfd_byte * hit_data, 4039 asection * sym_sec, 4040 bfd_vma offset, 4041 bfd_signed_vma addend, |
2679 bfd_vma val) | 4042 bfd_vma val, 4043 char **error_message) |
2680{ 2681 asection * s = 0; 2682 bfd_vma my_offset; 2683 unsigned long int tmp; 2684 long int ret_offset; 2685 struct elf_link_hash_entry * myh; 2686 struct elf32_arm_link_hash_table * globals; 2687 | 4044{ 4045 asection * s = 0; 4046 bfd_vma my_offset; 4047 unsigned long int tmp; 4048 long int ret_offset; 4049 struct elf_link_hash_entry * myh; 4050 struct elf32_arm_link_hash_table * globals; 4051 |
2688 myh = find_thumb_glue (info, name, input_bfd); | 4052 myh = find_thumb_glue (info, name, error_message); |
2689 if (myh == NULL) 2690 return FALSE; 2691 2692 globals = elf32_arm_hash_table (info); 2693 2694 BFD_ASSERT (globals != NULL); 2695 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2696 --- 18 unchanged lines hidden (view full) --- 2715 sym_sec->owner, input_bfd, name); 2716 2717 return FALSE; 2718 } 2719 2720 --my_offset; 2721 myh->root.u.def.value = my_offset; 2722 | 4053 if (myh == NULL) 4054 return FALSE; 4055 4056 globals = elf32_arm_hash_table (info); 4057 4058 BFD_ASSERT (globals != NULL); 4059 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 4060 --- 18 unchanged lines hidden (view full) --- 4079 sym_sec->owner, input_bfd, name); 4080 4081 return FALSE; 4082 } 4083 4084 --my_offset; 4085 myh->root.u.def.value = my_offset; 4086 |
2723 bfd_put_16 (output_bfd, (bfd_vma) t2a1_bx_pc_insn, 2724 s->contents + my_offset); | 4087 put_thumb_insn (globals, output_bfd, (bfd_vma) t2a1_bx_pc_insn, 4088 s->contents + my_offset); |
2725 | 4089 |
2726 bfd_put_16 (output_bfd, (bfd_vma) t2a2_noop_insn, 2727 s->contents + my_offset + 2); | 4090 put_thumb_insn (globals, output_bfd, (bfd_vma) t2a2_noop_insn, 4091 s->contents + my_offset + 2); |
2728 2729 ret_offset = 2730 /* Address of destination of the stub. */ 2731 ((bfd_signed_vma) val) 2732 - ((bfd_signed_vma) 2733 /* Offset from the start of the current section 2734 to the start of the stubs. */ 2735 (s->output_offset 2736 /* Offset of the start of this stub from the start of the stubs. */ 2737 + my_offset 2738 /* Address of the start of the current section. */ 2739 + s->output_section->vma) 2740 /* The branch instruction is 4 bytes into the stub. */ 2741 + 4 2742 /* ARM branches work from the pc of the instruction + 8. */ 2743 + 8); 2744 | 4092 4093 ret_offset = 4094 /* Address of destination of the stub. */ 4095 ((bfd_signed_vma) val) 4096 - ((bfd_signed_vma) 4097 /* Offset from the start of the current section 4098 to the start of the stubs. */ 4099 (s->output_offset 4100 /* Offset of the start of this stub from the start of the stubs. */ 4101 + my_offset 4102 /* Address of the start of the current section. */ 4103 + s->output_section->vma) 4104 /* The branch instruction is 4 bytes into the stub. */ 4105 + 4 4106 /* ARM branches work from the pc of the instruction + 8. */ 4107 + 8); 4108 |
2745 bfd_put_32 (output_bfd, 2746 (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF), 2747 s->contents + my_offset + 4); | 4109 put_arm_insn (globals, output_bfd, 4110 (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF), 4111 s->contents + my_offset + 4); |
2748 } 2749 2750 BFD_ASSERT (my_offset <= globals->thumb_glue_size); 2751 2752 /* Now go back and fix up the original BL insn to point to here. */ 2753 ret_offset = 2754 /* Address of where the stub is located. */ 2755 (s->output_section->vma + s->output_offset + my_offset) --- 10 unchanged lines hidden (view full) --- 2766 2767 bfd_put_32 (output_bfd, 2768 (bfd_vma) insert_thumb_branch (tmp, ret_offset), 2769 hit_data - input_section->vma); 2770 2771 return TRUE; 2772} 2773 | 4112 } 4113 4114 BFD_ASSERT (my_offset <= globals->thumb_glue_size); 4115 4116 /* Now go back and fix up the original BL insn to point to here. */ 4117 ret_offset = 4118 /* Address of where the stub is located. */ 4119 (s->output_section->vma + s->output_offset + my_offset) --- 10 unchanged lines hidden (view full) --- 4130 4131 bfd_put_32 (output_bfd, 4132 (bfd_vma) insert_thumb_branch (tmp, ret_offset), 4133 hit_data - input_section->vma); 4134 4135 return TRUE; 4136} 4137 |
2774/* Arm code calling a Thumb function. */ | 4138/* Populate an Arm to Thumb stub. Returns the stub symbol. */ |
2775 | 4139 |
2776static int 2777elf32_arm_to_thumb_stub (struct bfd_link_info * info, 2778 const char * name, 2779 bfd * input_bfd, 2780 bfd * output_bfd, 2781 asection * input_section, 2782 bfd_byte * hit_data, 2783 asection * sym_sec, 2784 bfd_vma offset, 2785 bfd_signed_vma addend, 2786 bfd_vma val) | 4140static struct elf_link_hash_entry * 4141elf32_arm_create_thumb_stub (struct bfd_link_info * info, 4142 const char * name, 4143 bfd * input_bfd, 4144 bfd * output_bfd, 4145 asection * sym_sec, 4146 bfd_vma val, 4147 asection *s, 4148 char **error_message) |
2787{ | 4149{ |
2788 unsigned long int tmp; | |
2789 bfd_vma my_offset; | 4150 bfd_vma my_offset; |
2790 asection * s; | |
2791 long int ret_offset; 2792 struct elf_link_hash_entry * myh; 2793 struct elf32_arm_link_hash_table * globals; 2794 | 4151 long int ret_offset; 4152 struct elf_link_hash_entry * myh; 4153 struct elf32_arm_link_hash_table * globals; 4154 |
2795 myh = find_arm_glue (info, name, input_bfd); | 4155 myh = find_arm_glue (info, name, error_message); |
2796 if (myh == NULL) | 4156 if (myh == NULL) |
2797 return FALSE; | 4157 return NULL; |
2798 2799 globals = elf32_arm_hash_table (info); 2800 2801 BFD_ASSERT (globals != NULL); 2802 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 2803 2804 my_offset = myh->root.u.def.value; | 4158 4159 globals = elf32_arm_hash_table (info); 4160 4161 BFD_ASSERT (globals != NULL); 4162 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 4163 4164 my_offset = myh->root.u.def.value; |
2805 s = bfd_get_section_by_name (globals->bfd_of_glue_owner, 2806 ARM2THUMB_GLUE_SECTION_NAME); 2807 BFD_ASSERT (s != NULL); 2808 BFD_ASSERT (s->contents != NULL); 2809 BFD_ASSERT (s->output_section != NULL); | |
2810 2811 if ((my_offset & 0x01) == 0x01) 2812 { 2813 if (sym_sec != NULL 2814 && sym_sec->owner != NULL 2815 && !INTERWORK_FLAG (sym_sec->owner)) 2816 { 2817 (*_bfd_error_handler) 2818 (_("%B(%s): warning: interworking not enabled.\n" 2819 " first occurrence: %B: arm call to thumb"), 2820 sym_sec->owner, input_bfd, name); 2821 } 2822 2823 --my_offset; 2824 myh->root.u.def.value = my_offset; 2825 | 4165 4166 if ((my_offset & 0x01) == 0x01) 4167 { 4168 if (sym_sec != NULL 4169 && sym_sec->owner != NULL 4170 && !INTERWORK_FLAG (sym_sec->owner)) 4171 { 4172 (*_bfd_error_handler) 4173 (_("%B(%s): warning: interworking not enabled.\n" 4174 " first occurrence: %B: arm call to thumb"), 4175 sym_sec->owner, input_bfd, name); 4176 } 4177 4178 --my_offset; 4179 myh->root.u.def.value = my_offset; 4180 |
2826 if ((info->shared || globals->root.is_relocatable_executable)) | 4181 if (info->shared || globals->root.is_relocatable_executable 4182 || globals->pic_veneer) |
2827 { 2828 /* For relocatable objects we can't use absolute addresses, 2829 so construct the address from a relative offset. */ 2830 /* TODO: If the offset is small it's probably worth 2831 constructing the address with adds. */ | 4183 { 4184 /* For relocatable objects we can't use absolute addresses, 4185 so construct the address from a relative offset. */ 4186 /* TODO: If the offset is small it's probably worth 4187 constructing the address with adds. */ |
2832 bfd_put_32 (output_bfd, (bfd_vma) a2t1p_ldr_insn, 2833 s->contents + my_offset); 2834 bfd_put_32 (output_bfd, (bfd_vma) a2t2p_add_pc_insn, 2835 s->contents + my_offset + 4); 2836 bfd_put_32 (output_bfd, (bfd_vma) a2t3p_bx_r12_insn, 2837 s->contents + my_offset + 8); | 4188 put_arm_insn (globals, output_bfd, (bfd_vma) a2t1p_ldr_insn, 4189 s->contents + my_offset); 4190 put_arm_insn (globals, output_bfd, (bfd_vma) a2t2p_add_pc_insn, 4191 s->contents + my_offset + 4); 4192 put_arm_insn (globals, output_bfd, (bfd_vma) a2t3p_bx_r12_insn, 4193 s->contents + my_offset + 8); |
2838 /* Adjust the offset by 4 for the position of the add, 2839 and 8 for the pipeline offset. */ 2840 ret_offset = (val - (s->output_offset 2841 + s->output_section->vma 2842 + my_offset + 12)) 2843 | 1; 2844 bfd_put_32 (output_bfd, ret_offset, 2845 s->contents + my_offset + 12); 2846 } | 4194 /* Adjust the offset by 4 for the position of the add, 4195 and 8 for the pipeline offset. */ 4196 ret_offset = (val - (s->output_offset 4197 + s->output_section->vma 4198 + my_offset + 12)) 4199 | 1; 4200 bfd_put_32 (output_bfd, ret_offset, 4201 s->contents + my_offset + 12); 4202 } |
2847 else | 4203 else if (globals->use_blx) |
2848 { | 4204 { |
2849 bfd_put_32 (output_bfd, (bfd_vma) a2t1_ldr_insn, 2850 s->contents + my_offset); | 4205 put_arm_insn (globals, output_bfd, (bfd_vma) a2t1v5_ldr_insn, 4206 s->contents + my_offset); |
2851 | 4207 |
2852 bfd_put_32 (output_bfd, (bfd_vma) a2t2_bx_r12_insn, | 4208 /* It's a thumb address. Add the low order bit. */ 4209 bfd_put_32 (output_bfd, val | a2t2v5_func_addr_insn, |
2853 s->contents + my_offset + 4); | 4210 s->contents + my_offset + 4); |
4211 } 4212 else 4213 { 4214 put_arm_insn (globals, output_bfd, (bfd_vma) a2t1_ldr_insn, 4215 s->contents + my_offset); |
|
2854 | 4216 |
4217 put_arm_insn (globals, output_bfd, (bfd_vma) a2t2_bx_r12_insn, 4218 s->contents + my_offset + 4); 4219 |
|
2855 /* It's a thumb address. Add the low order bit. */ 2856 bfd_put_32 (output_bfd, val | a2t3_func_addr_insn, 2857 s->contents + my_offset + 8); 2858 } 2859 } 2860 2861 BFD_ASSERT (my_offset <= globals->arm_glue_size); 2862 | 4220 /* It's a thumb address. Add the low order bit. */ 4221 bfd_put_32 (output_bfd, val | a2t3_func_addr_insn, 4222 s->contents + my_offset + 8); 4223 } 4224 } 4225 4226 BFD_ASSERT (my_offset <= globals->arm_glue_size); 4227 |
4228 return myh; 4229} 4230 4231/* Arm code calling a Thumb function. */ 4232 4233static int 4234elf32_arm_to_thumb_stub (struct bfd_link_info * info, 4235 const char * name, 4236 bfd * input_bfd, 4237 bfd * output_bfd, 4238 asection * input_section, 4239 bfd_byte * hit_data, 4240 asection * sym_sec, 4241 bfd_vma offset, 4242 bfd_signed_vma addend, 4243 bfd_vma val, 4244 char **error_message) 4245{ 4246 unsigned long int tmp; 4247 bfd_vma my_offset; 4248 asection * s; 4249 long int ret_offset; 4250 struct elf_link_hash_entry * myh; 4251 struct elf32_arm_link_hash_table * globals; 4252 4253 globals = elf32_arm_hash_table (info); 4254 4255 BFD_ASSERT (globals != NULL); 4256 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 4257 4258 s = bfd_get_section_by_name (globals->bfd_of_glue_owner, 4259 ARM2THUMB_GLUE_SECTION_NAME); 4260 BFD_ASSERT (s != NULL); 4261 BFD_ASSERT (s->contents != NULL); 4262 BFD_ASSERT (s->output_section != NULL); 4263 4264 myh = elf32_arm_create_thumb_stub (info, name, input_bfd, output_bfd, 4265 sym_sec, val, s, error_message); 4266 if (!myh) 4267 return FALSE; 4268 4269 my_offset = myh->root.u.def.value; |
|
2863 tmp = bfd_get_32 (input_bfd, hit_data); 2864 tmp = tmp & 0xFF000000; 2865 2866 /* Somehow these are both 4 too far, so subtract 8. */ 2867 ret_offset = (s->output_offset 2868 + my_offset 2869 + s->output_section->vma 2870 - (input_section->output_offset 2871 + input_section->output_section->vma 2872 + offset + addend) 2873 - 8); 2874 2875 tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF); 2876 2877 bfd_put_32 (output_bfd, (bfd_vma) tmp, hit_data - input_section->vma); 2878 2879 return TRUE; 2880} 2881 | 4270 tmp = bfd_get_32 (input_bfd, hit_data); 4271 tmp = tmp & 0xFF000000; 4272 4273 /* Somehow these are both 4 too far, so subtract 8. */ 4274 ret_offset = (s->output_offset 4275 + my_offset 4276 + s->output_section->vma 4277 - (input_section->output_offset 4278 + input_section->output_section->vma 4279 + offset + addend) 4280 - 8); 4281 4282 tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF); 4283 4284 bfd_put_32 (output_bfd, (bfd_vma) tmp, hit_data - input_section->vma); 4285 4286 return TRUE; 4287} 4288 |
4289/* Populate Arm stub for an exported Thumb function. */ 4290 4291static bfd_boolean 4292elf32_arm_to_thumb_export_stub (struct elf_link_hash_entry *h, void * inf) 4293{ 4294 struct bfd_link_info * info = (struct bfd_link_info *) inf; 4295 asection * s; 4296 struct elf_link_hash_entry * myh; 4297 struct elf32_arm_link_hash_entry *eh; 4298 struct elf32_arm_link_hash_table * globals; 4299 asection *sec; 4300 bfd_vma val; 4301 char *error_message; 4302 4303 eh = elf32_arm_hash_entry(h); 4304 /* Allocate stubs for exported Thumb functions on v4t. */ 4305 if (eh->export_glue == NULL) 4306 return TRUE; 4307 4308 globals = elf32_arm_hash_table (info); 4309 4310 BFD_ASSERT (globals != NULL); 4311 BFD_ASSERT (globals->bfd_of_glue_owner != NULL); 4312 4313 s = bfd_get_section_by_name (globals->bfd_of_glue_owner, 4314 ARM2THUMB_GLUE_SECTION_NAME); 4315 BFD_ASSERT (s != NULL); 4316 BFD_ASSERT (s->contents != NULL); 4317 BFD_ASSERT (s->output_section != NULL); 4318 4319 sec = eh->export_glue->root.u.def.section; 4320 4321 BFD_ASSERT (sec->output_section != NULL); 4322 4323 val = eh->export_glue->root.u.def.value + sec->output_offset 4324 + sec->output_section->vma; 4325 myh = elf32_arm_create_thumb_stub (info, h->root.root.string, 4326 h->root.u.def.section->owner, 4327 globals->obfd, sec, val, s, 4328 &error_message); 4329 BFD_ASSERT (myh); 4330 return TRUE; 4331} 4332 4333/* Generate Arm stubs for exported Thumb symbols. */ 4334static void 4335elf32_arm_begin_write_processing (bfd *abfd ATTRIBUTE_UNUSED, 4336 struct bfd_link_info *link_info) 4337{ 4338 struct elf32_arm_link_hash_table * globals; 4339 4340 if (!link_info) 4341 return; 4342 4343 globals = elf32_arm_hash_table (link_info); 4344 /* If blx is available then exported Thumb symbols are OK and there is 4345 nothing to do. */ 4346 if (globals->use_blx) 4347 return; 4348 4349 elf_link_hash_traverse (&globals->root, elf32_arm_to_thumb_export_stub, 4350 link_info); 4351} 4352 |
|
2882/* Some relocations map to different relocations depending on the 2883 target. Return the real relocation. */ 2884static int 2885arm_real_reloc_type (struct elf32_arm_link_hash_table * globals, 2886 int r_type) 2887{ 2888 switch (r_type) 2889 { --- 49 unchanged lines hidden (view full) --- 2939 if (value > 0xfff) 2940 return bfd_reloc_overflow; 2941 2942 value |= bfd_get_32 (abfd, data) & 0xfffff000; 2943 bfd_put_32 (abfd, value, data); 2944 return bfd_reloc_ok; 2945} 2946 | 4353/* Some relocations map to different relocations depending on the 4354 target. Return the real relocation. */ 4355static int 4356arm_real_reloc_type (struct elf32_arm_link_hash_table * globals, 4357 int r_type) 4358{ 4359 switch (r_type) 4360 { --- 49 unchanged lines hidden (view full) --- 4410 if (value > 0xfff) 4411 return bfd_reloc_overflow; 4412 4413 value |= bfd_get_32 (abfd, data) & 0xfffff000; 4414 bfd_put_32 (abfd, value, data); 4415 return bfd_reloc_ok; 4416} 4417 |
4418/* For a given value of n, calculate the value of G_n as required to 4419 deal with group relocations. We return it in the form of an 4420 encoded constant-and-rotation, together with the final residual. If n is 4421 specified as less than zero, then final_residual is filled with the 4422 input value and no further action is performed. */ 4423 4424static bfd_vma 4425calculate_group_reloc_mask (bfd_vma value, int n, bfd_vma *final_residual) 4426{ 4427 int current_n; 4428 bfd_vma g_n; 4429 bfd_vma encoded_g_n = 0; 4430 bfd_vma residual = value; /* Also known as Y_n. */ 4431 4432 for (current_n = 0; current_n <= n; current_n++) 4433 { 4434 int shift; 4435 4436 /* Calculate which part of the value to mask. */ 4437 if (residual == 0) 4438 shift = 0; 4439 else 4440 { 4441 int msb; 4442 4443 /* Determine the most significant bit in the residual and 4444 align the resulting value to a 2-bit boundary. */ 4445 for (msb = 30; msb >= 0; msb -= 2) 4446 if (residual & (3 << msb)) 4447 break; 4448 4449 /* The desired shift is now (msb - 6), or zero, whichever 4450 is the greater. */ 4451 shift = msb - 6; 4452 if (shift < 0) 4453 shift = 0; 4454 } 4455 4456 /* Calculate g_n in 32-bit as well as encoded constant+rotation form. */ 4457 g_n = residual & (0xff << shift); 4458 encoded_g_n = (g_n >> shift) 4459 | ((g_n <= 0xff ? 0 : (32 - shift) / 2) << 8); 4460 4461 /* Calculate the residual for the next time around. */ 4462 residual &= ~g_n; 4463 } 4464 4465 *final_residual = residual; 4466 4467 return encoded_g_n; 4468} 4469 4470/* Given an ARM instruction, determine whether it is an ADD or a SUB. 4471 Returns 1 if it is an ADD, -1 if it is a SUB, and 0 otherwise. */ 4472static int 4473identify_add_or_sub(bfd_vma insn) 4474{ 4475 int opcode = insn & 0x1e00000; 4476 4477 if (opcode == 1 << 23) /* ADD */ 4478 return 1; 4479 4480 if (opcode == 1 << 22) /* SUB */ 4481 return -1; 4482 4483 return 0; 4484} 4485 4486/* Determine if we're dealing with a Thumb-2 object. */ 4487 4488static int using_thumb2 (struct elf32_arm_link_hash_table *globals) 4489{ 4490 int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC, 4491 Tag_CPU_arch); 4492 return arch == TAG_CPU_ARCH_V6T2 || arch >= TAG_CPU_ARCH_V7; 4493} 4494 |
|
2947/* Perform a relocation as part of a final link. */ 2948 2949static bfd_reloc_status_type 2950elf32_arm_final_link_relocate (reloc_howto_type * howto, 2951 bfd * input_bfd, 2952 bfd * output_bfd, 2953 asection * input_section, 2954 bfd_byte * contents, 2955 Elf_Internal_Rela * rel, 2956 bfd_vma value, 2957 struct bfd_link_info * info, 2958 asection * sym_sec, 2959 const char * sym_name, 2960 int sym_flags, 2961 struct elf_link_hash_entry * h, | 4495/* Perform a relocation as part of a final link. */ 4496 4497static bfd_reloc_status_type 4498elf32_arm_final_link_relocate (reloc_howto_type * howto, 4499 bfd * input_bfd, 4500 bfd * output_bfd, 4501 asection * input_section, 4502 bfd_byte * contents, 4503 Elf_Internal_Rela * rel, 4504 bfd_vma value, 4505 struct bfd_link_info * info, 4506 asection * sym_sec, 4507 const char * sym_name, 4508 int sym_flags, 4509 struct elf_link_hash_entry * h, |
2962 bfd_boolean * unresolved_reloc_p) | 4510 bfd_boolean * unresolved_reloc_p, 4511 char **error_message) |
2963{ 2964 unsigned long r_type = howto->type; 2965 unsigned long r_symndx; 2966 bfd_byte * hit_data = contents + rel->r_offset; 2967 bfd * dynobj = NULL; 2968 Elf_Internal_Shdr * symtab_hdr; 2969 struct elf_link_hash_entry ** sym_hashes; 2970 bfd_vma * local_got_offsets; --- 60 unchanged lines hidden (view full) --- 3031 return bfd_reloc_ok; 3032 3033 case R_ARM_ABS12: 3034 if (!globals->vxworks_p) 3035 return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend); 3036 3037 case R_ARM_PC24: 3038 case R_ARM_ABS32: | 4512{ 4513 unsigned long r_type = howto->type; 4514 unsigned long r_symndx; 4515 bfd_byte * hit_data = contents + rel->r_offset; 4516 bfd * dynobj = NULL; 4517 Elf_Internal_Shdr * symtab_hdr; 4518 struct elf_link_hash_entry ** sym_hashes; 4519 bfd_vma * local_got_offsets; --- 60 unchanged lines hidden (view full) --- 4580 return bfd_reloc_ok; 4581 4582 case R_ARM_ABS12: 4583 if (!globals->vxworks_p) 4584 return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend); 4585 4586 case R_ARM_PC24: 4587 case R_ARM_ABS32: |
4588 case R_ARM_ABS32_NOI: |
|
3039 case R_ARM_REL32: | 4589 case R_ARM_REL32: |
4590 case R_ARM_REL32_NOI: |
|
3040 case R_ARM_CALL: 3041 case R_ARM_JUMP24: 3042 case R_ARM_XPC25: 3043 case R_ARM_PREL31: 3044 case R_ARM_PLT32: | 4591 case R_ARM_CALL: 4592 case R_ARM_JUMP24: 4593 case R_ARM_XPC25: 4594 case R_ARM_PREL31: 4595 case R_ARM_PLT32: |
3045 /* r_symndx will be zero only for relocs against symbols 3046 from removed linkonce sections, or sections discarded by 3047 a linker script. */ 3048 if (r_symndx == 0) 3049 return bfd_reloc_ok; 3050 | |
3051 /* Handle relocations which should use the PLT entry. ABS32/REL32 3052 will use the symbol's value, which may point to a PLT entry, but we 3053 don't need to handle that here. If we created a PLT entry, all 3054 branches in this object should go to it. */ | 4596 /* Handle relocations which should use the PLT entry. ABS32/REL32 4597 will use the symbol's value, which may point to a PLT entry, but we 4598 don't need to handle that here. If we created a PLT entry, all 4599 branches in this object should go to it. */ |
3055 if ((r_type != R_ARM_ABS32 && r_type != R_ARM_REL32) | 4600 if ((r_type != R_ARM_ABS32 && r_type != R_ARM_REL32 4601 && r_type != R_ARM_ABS32_NOI && r_type != R_ARM_REL32_NOI) |
3056 && h != NULL 3057 && splt != NULL 3058 && h->plt.offset != (bfd_vma) -1) 3059 { 3060 /* If we've created a .plt section, and assigned a PLT entry to 3061 this function, it should not be known to bind locally. If 3062 it were, we would have cleared the PLT entry. */ 3063 BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info, h)); --- 7 unchanged lines hidden (view full) --- 3071 rel->r_addend); 3072 } 3073 3074 /* When generating a shared object or relocatable executable, these 3075 relocations are copied into the output file to be resolved at 3076 run time. */ 3077 if ((info->shared || globals->root.is_relocatable_executable) 3078 && (input_section->flags & SEC_ALLOC) | 4602 && h != NULL 4603 && splt != NULL 4604 && h->plt.offset != (bfd_vma) -1) 4605 { 4606 /* If we've created a .plt section, and assigned a PLT entry to 4607 this function, it should not be known to bind locally. If 4608 it were, we would have cleared the PLT entry. */ 4609 BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info, h)); --- 7 unchanged lines hidden (view full) --- 4617 rel->r_addend); 4618 } 4619 4620 /* When generating a shared object or relocatable executable, these 4621 relocations are copied into the output file to be resolved at 4622 run time. */ 4623 if ((info->shared || globals->root.is_relocatable_executable) 4624 && (input_section->flags & SEC_ALLOC) |
3079 && (r_type != R_ARM_REL32 | 4625 && ((r_type != R_ARM_REL32 && r_type != R_ARM_REL32_NOI) |
3080 || !SYMBOL_CALLS_LOCAL (info, h)) 3081 && (h == NULL 3082 || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT 3083 || h->root.type != bfd_link_hash_undefweak) 3084 && r_type != R_ARM_PC24 3085 && r_type != R_ARM_CALL 3086 && r_type != R_ARM_JUMP24 3087 && r_type != R_ARM_PREL31 --- 48 unchanged lines hidden (view full) --- 3136 { 3137 int symbol; 3138 3139 /* This symbol is local, or marked to become local. */ 3140 if (sym_flags == STT_ARM_TFUNC) 3141 value |= 1; 3142 if (globals->symbian_p) 3143 { | 4626 || !SYMBOL_CALLS_LOCAL (info, h)) 4627 && (h == NULL 4628 || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT 4629 || h->root.type != bfd_link_hash_undefweak) 4630 && r_type != R_ARM_PC24 4631 && r_type != R_ARM_CALL 4632 && r_type != R_ARM_JUMP24 4633 && r_type != R_ARM_PREL31 --- 48 unchanged lines hidden (view full) --- 4682 { 4683 int symbol; 4684 4685 /* This symbol is local, or marked to become local. */ 4686 if (sym_flags == STT_ARM_TFUNC) 4687 value |= 1; 4688 if (globals->symbian_p) 4689 { |
4690 asection *osec; 4691 |
|
3144 /* On Symbian OS, the data segment and text segement 3145 can be relocated independently. Therefore, we 3146 must indicate the segment to which this 3147 relocation is relative. The BPABI allows us to 3148 use any symbol in the right segment; we just use 3149 the section symbol as it is convenient. (We 3150 cannot use the symbol given by "h" directly as it | 4692 /* On Symbian OS, the data segment and text segement 4693 can be relocated independently. Therefore, we 4694 must indicate the segment to which this 4695 relocation is relative. The BPABI allows us to 4696 use any symbol in the right segment; we just use 4697 the section symbol as it is convenient. (We 4698 cannot use the symbol given by "h" directly as it |
3151 will not appear in the dynamic symbol table.) */ | 4699 will not appear in the dynamic symbol table.) 4700 4701 Note that the dynamic linker ignores the section 4702 symbol value, so we don't subtract osec->vma 4703 from the emitted reloc addend. */ |
3152 if (sym_sec) | 4704 if (sym_sec) |
3153 symbol = elf_section_data (sym_sec->output_section)->dynindx; | 4705 osec = sym_sec->output_section; |
3154 else | 4706 else |
3155 symbol = elf_section_data (input_section->output_section)->dynindx; | 4707 osec = input_section->output_section; 4708 symbol = elf_section_data (osec)->dynindx; 4709 if (symbol == 0) 4710 { 4711 struct elf_link_hash_table *htab = elf_hash_table (info); 4712 4713 if ((osec->flags & SEC_READONLY) == 0 4714 && htab->data_index_section != NULL) 4715 osec = htab->data_index_section; 4716 else 4717 osec = htab->text_index_section; 4718 symbol = elf_section_data (osec)->dynindx; 4719 } |
3156 BFD_ASSERT (symbol != 0); 3157 } 3158 else 3159 /* On SVR4-ish systems, the dynamic loader cannot 3160 relocate the text and data segments independently, 3161 so the symbol does not matter. */ 3162 symbol = 0; 3163 outrel.r_info = ELF32_R_INFO (symbol, R_ARM_RELATIVE); --- 38 unchanged lines hidden (view full) --- 3202 input_bfd, 3203 h ? h->root.root.string : "(local)"); 3204 } 3205 else if (r_type != R_ARM_CALL || !globals->use_blx) 3206 { 3207 /* Check for Arm calling Thumb function. */ 3208 if (sym_flags == STT_ARM_TFUNC) 3209 { | 4720 BFD_ASSERT (symbol != 0); 4721 } 4722 else 4723 /* On SVR4-ish systems, the dynamic loader cannot 4724 relocate the text and data segments independently, 4725 so the symbol does not matter. */ 4726 symbol = 0; 4727 outrel.r_info = ELF32_R_INFO (symbol, R_ARM_RELATIVE); --- 38 unchanged lines hidden (view full) --- 4766 input_bfd, 4767 h ? h->root.root.string : "(local)"); 4768 } 4769 else if (r_type != R_ARM_CALL || !globals->use_blx) 4770 { 4771 /* Check for Arm calling Thumb function. */ 4772 if (sym_flags == STT_ARM_TFUNC) 4773 { |
3210 elf32_arm_to_thumb_stub (info, sym_name, input_bfd, 3211 output_bfd, input_section, 3212 hit_data, sym_sec, rel->r_offset, 3213 signed_addend, value); 3214 return bfd_reloc_ok; | 4774 if (elf32_arm_to_thumb_stub (info, sym_name, input_bfd, 4775 output_bfd, input_section, 4776 hit_data, sym_sec, rel->r_offset, 4777 signed_addend, value, 4778 error_message)) 4779 return bfd_reloc_ok; 4780 else 4781 return bfd_reloc_dangerous; |
3215 } 3216 } 3217 3218 /* The ARM ELF ABI says that this reloc is computed as: S - P + A 3219 where: 3220 S is the address of the symbol in the relocation. 3221 P is address of the instruction being relocated. 3222 A is the addend (extracted from the instruction) in bytes. --- 18 unchanged lines hidden (view full) --- 3241 value += (signed_addend << howto->size); 3242 else 3243 /* RELA addends do not have to be adjusted by howto->size. */ 3244 value += signed_addend; 3245 3246 signed_addend = value; 3247 signed_addend >>= howto->rightshift; 3248 | 4782 } 4783 } 4784 4785 /* The ARM ELF ABI says that this reloc is computed as: S - P + A 4786 where: 4787 S is the address of the symbol in the relocation. 4788 P is address of the instruction being relocated. 4789 A is the addend (extracted from the instruction) in bytes. --- 18 unchanged lines hidden (view full) --- 4808 value += (signed_addend << howto->size); 4809 else 4810 /* RELA addends do not have to be adjusted by howto->size. */ 4811 value += signed_addend; 4812 4813 signed_addend = value; 4814 signed_addend >>= howto->rightshift; 4815 |
3249 /* It is not an error for an undefined weak reference to be 3250 out of range. Any program that branches to such a symbol 3251 is going to crash anyway, so there is no point worrying 3252 about getting the destination exactly right. */ 3253 if (! h || h->root.type != bfd_link_hash_undefweak) | 4816 /* A branch to an undefined weak symbol is turned into a jump to 4817 the next instruction. */ 4818 if (h && h->root.type == bfd_link_hash_undefweak) |
3254 { | 4819 { |
4820 value = (bfd_get_32 (input_bfd, hit_data) & 0xf0000000) 4821 | 0x0affffff; 4822 } 4823 else 4824 { |
|
3255 /* Perform a signed range check. */ 3256 if ( signed_addend > ((bfd_signed_vma) (howto->dst_mask >> 1)) 3257 || signed_addend < - ((bfd_signed_vma) ((howto->dst_mask + 1) >> 1))) 3258 return bfd_reloc_overflow; | 4825 /* Perform a signed range check. */ 4826 if ( signed_addend > ((bfd_signed_vma) (howto->dst_mask >> 1)) 4827 || signed_addend < - ((bfd_signed_vma) ((howto->dst_mask + 1) >> 1))) 4828 return bfd_reloc_overflow; |
3259 } | |
3260 | 4829 |
3261 addend = (value & 2); | 4830 addend = (value & 2); |
3262 | 4831 |
3263 value = (signed_addend & howto->dst_mask) 3264 | (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask)); | 4832 value = (signed_addend & howto->dst_mask) 4833 | (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask)); |
3265 | 4834 |
3266 /* Set the H bit in the BLX instruction. */ 3267 if (sym_flags == STT_ARM_TFUNC) 3268 { 3269 if (addend) 3270 value |= (1 << 24); 3271 else 3272 value &= ~(bfd_vma)(1 << 24); 3273 } 3274 if (r_type == R_ARM_CALL) 3275 { 3276 /* Select the correct instruction (BL or BLX). */ | 4835 /* Set the H bit in the BLX instruction. */ |
3277 if (sym_flags == STT_ARM_TFUNC) | 4836 if (sym_flags == STT_ARM_TFUNC) |
3278 value |= (1 << 28); 3279 else | |
3280 { | 4837 { |
3281 value &= ~(bfd_vma)(1 << 28); 3282 value |= (1 << 24); | 4838 if (addend) 4839 value |= (1 << 24); 4840 else 4841 value &= ~(bfd_vma)(1 << 24); |
3283 } | 4842 } |
4843 if (r_type == R_ARM_CALL) 4844 { 4845 /* Select the correct instruction (BL or BLX). */ 4846 if (sym_flags == STT_ARM_TFUNC) 4847 value |= (1 << 28); 4848 else 4849 { 4850 value &= ~(bfd_vma)(1 << 28); 4851 value |= (1 << 24); 4852 } 4853 } |
|
3284 } 3285 break; 3286 3287 case R_ARM_ABS32: 3288 value += addend; 3289 if (sym_flags == STT_ARM_TFUNC) 3290 value |= 1; 3291 break; 3292 | 4854 } 4855 break; 4856 4857 case R_ARM_ABS32: 4858 value += addend; 4859 if (sym_flags == STT_ARM_TFUNC) 4860 value |= 1; 4861 break; 4862 |
4863 case R_ARM_ABS32_NOI: 4864 value += addend; 4865 break; 4866 |
|
3293 case R_ARM_REL32: 3294 value += addend; 3295 if (sym_flags == STT_ARM_TFUNC) 3296 value |= 1; 3297 value -= (input_section->output_section->vma 3298 + input_section->output_offset + rel->r_offset); 3299 break; 3300 | 4867 case R_ARM_REL32: 4868 value += addend; 4869 if (sym_flags == STT_ARM_TFUNC) 4870 value |= 1; 4871 value -= (input_section->output_section->vma 4872 + input_section->output_offset + rel->r_offset); 4873 break; 4874 |
4875 case R_ARM_REL32_NOI: 4876 value += addend; 4877 value -= (input_section->output_section->vma 4878 + input_section->output_offset + rel->r_offset); 4879 break; 4880 |
|
3301 case R_ARM_PREL31: 3302 value -= (input_section->output_section->vma 3303 + input_section->output_offset + rel->r_offset); 3304 value += signed_addend; 3305 if (! h || h->root.type != bfd_link_hash_undefweak) 3306 { 3307 /* Check for overflow */ 3308 if ((value ^ (value >> 1)) & (1 << 30)) --- 41 unchanged lines hidden (view full) --- 3350 if ((long) value > 0x1f || (long) value < -0x10) 3351 return bfd_reloc_overflow; 3352 3353 /* ??? Value needs to be properly shifted into place first. */ 3354 value |= bfd_get_16 (input_bfd, hit_data) & 0xf83f; 3355 bfd_put_16 (input_bfd, value, hit_data); 3356 return bfd_reloc_ok; 3357 | 4881 case R_ARM_PREL31: 4882 value -= (input_section->output_section->vma 4883 + input_section->output_offset + rel->r_offset); 4884 value += signed_addend; 4885 if (! h || h->root.type != bfd_link_hash_undefweak) 4886 { 4887 /* Check for overflow */ 4888 if ((value ^ (value >> 1)) & (1 << 30)) --- 41 unchanged lines hidden (view full) --- 4930 if ((long) value > 0x1f || (long) value < -0x10) 4931 return bfd_reloc_overflow; 4932 4933 /* ??? Value needs to be properly shifted into place first. */ 4934 value |= bfd_get_16 (input_bfd, hit_data) & 0xf83f; 4935 bfd_put_16 (input_bfd, value, hit_data); 4936 return bfd_reloc_ok; 4937 |
4938 case R_ARM_THM_ALU_PREL_11_0: 4939 /* Corresponds to: addw.w reg, pc, #offset (and similarly for subw). */ 4940 { 4941 bfd_vma insn; 4942 bfd_signed_vma relocation; 4943 4944 insn = (bfd_get_16 (input_bfd, hit_data) << 16) 4945 | bfd_get_16 (input_bfd, hit_data + 2); 4946 4947 if (globals->use_rel) 4948 { 4949 signed_addend = (insn & 0xff) | ((insn & 0x7000) >> 4) 4950 | ((insn & (1 << 26)) >> 15); 4951 if (insn & 0xf00000) 4952 signed_addend = -signed_addend; 4953 } 4954 4955 relocation = value + signed_addend; 4956 relocation -= (input_section->output_section->vma 4957 + input_section->output_offset 4958 + rel->r_offset); 4959 4960 value = abs (relocation); 4961 4962 if (value >= 0x1000) 4963 return bfd_reloc_overflow; 4964 4965 insn = (insn & 0xfb0f8f00) | (value & 0xff) 4966 | ((value & 0x700) << 4) 4967 | ((value & 0x800) << 15); 4968 if (relocation < 0) 4969 insn |= 0xa00000; 4970 4971 bfd_put_16 (input_bfd, insn >> 16, hit_data); 4972 bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2); 4973 4974 return bfd_reloc_ok; 4975 } 4976 4977 case R_ARM_THM_PC12: 4978 /* Corresponds to: ldr.w reg, [pc, #offset]. */ 4979 { 4980 bfd_vma insn; 4981 bfd_signed_vma relocation; 4982 4983 insn = (bfd_get_16 (input_bfd, hit_data) << 16) 4984 | bfd_get_16 (input_bfd, hit_data + 2); 4985 4986 if (globals->use_rel) 4987 { 4988 signed_addend = insn & 0xfff; 4989 if (!(insn & (1 << 23))) 4990 signed_addend = -signed_addend; 4991 } 4992 4993 relocation = value + signed_addend; 4994 relocation -= (input_section->output_section->vma 4995 + input_section->output_offset 4996 + rel->r_offset); 4997 4998 value = abs (relocation); 4999 5000 if (value >= 0x1000) 5001 return bfd_reloc_overflow; 5002 5003 insn = (insn & 0xff7ff000) | value; 5004 if (relocation >= 0) 5005 insn |= (1 << 23); 5006 5007 bfd_put_16 (input_bfd, insn >> 16, hit_data); 5008 bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2); 5009 5010 return bfd_reloc_ok; 5011 } 5012 |
|
3358 case R_ARM_THM_XPC22: 3359 case R_ARM_THM_CALL: 3360 /* Thumb BL (branch long instruction). */ 3361 { 3362 bfd_vma relocation; | 5013 case R_ARM_THM_XPC22: 5014 case R_ARM_THM_CALL: 5015 /* Thumb BL (branch long instruction). */ 5016 { 5017 bfd_vma relocation; |
5018 bfd_vma reloc_sign; |
|
3363 bfd_boolean overflow = FALSE; 3364 bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data); 3365 bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2); | 5019 bfd_boolean overflow = FALSE; 5020 bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data); 5021 bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2); |
3366 bfd_signed_vma reloc_signed_max = ((1 << (howto->bitsize - 1)) - 1) >> howto->rightshift; 3367 bfd_signed_vma reloc_signed_min = ~ reloc_signed_max; | 5022 bfd_signed_vma reloc_signed_max; 5023 bfd_signed_vma reloc_signed_min; |
3368 bfd_vma check; 3369 bfd_signed_vma signed_check; | 5024 bfd_vma check; 5025 bfd_signed_vma signed_check; |
5026 int bitsize; 5027 int thumb2 = using_thumb2 (globals); |
|
3370 | 5028 |
3371 /* Need to refetch the addend and squish the two 11 bit pieces 3372 together. */ | 5029 /* A branch to an undefined weak symbol is turned into a jump to 5030 the next instruction. */ 5031 if (h && h->root.type == bfd_link_hash_undefweak) 5032 { 5033 bfd_put_16 (input_bfd, 0xe000, hit_data); 5034 bfd_put_16 (input_bfd, 0xbf00, hit_data + 2); 5035 return bfd_reloc_ok; 5036 } 5037 5038 /* Fetch the addend. We use the Thumb-2 encoding (backwards compatible 5039 with Thumb-1) involving the J1 and J2 bits. */ |
3373 if (globals->use_rel) 3374 { | 5040 if (globals->use_rel) 5041 { |
3375 bfd_vma upper = upper_insn & 0x7ff; 3376 bfd_vma lower = lower_insn & 0x7ff; 3377 upper = (upper ^ 0x400) - 0x400; /* Sign extend. */ 3378 addend = (upper << 12) | (lower << 1); | 5042 bfd_vma s = (upper_insn & (1 << 10)) >> 10; 5043 bfd_vma upper = upper_insn & 0x3ff; 5044 bfd_vma lower = lower_insn & 0x7ff; 5045 bfd_vma j1 = (lower_insn & (1 << 13)) >> 13; 5046 bfd_vma j2 = (lower_insn & (1 << 11)) >> 11; 5047 bfd_vma i1 = j1 ^ s ? 0 : 1; 5048 bfd_vma i2 = j2 ^ s ? 0 : 1; 5049 5050 addend = (i1 << 23) | (i2 << 22) | (upper << 12) | (lower << 1); 5051 /* Sign extend. */ 5052 addend = (addend | ((s ? 0 : 1) << 24)) - (1 << 24); 5053 |
3379 signed_addend = addend; 3380 } 3381 3382 if (r_type == R_ARM_THM_XPC22) 3383 { 3384 /* Check for Thumb to Thumb call. */ 3385 /* FIXME: Should we translate the instruction into a BL 3386 instruction instead ? */ --- 15 unchanged lines hidden (view full) --- 3402 { 3403 if (globals->use_blx) 3404 { 3405 /* Convert BL to BLX. */ 3406 lower_insn = (lower_insn & ~0x1000) | 0x0800; 3407 } 3408 else if (elf32_thumb_to_arm_stub 3409 (info, sym_name, input_bfd, output_bfd, input_section, | 5054 signed_addend = addend; 5055 } 5056 5057 if (r_type == R_ARM_THM_XPC22) 5058 { 5059 /* Check for Thumb to Thumb call. */ 5060 /* FIXME: Should we translate the instruction into a BL 5061 instruction instead ? */ --- 15 unchanged lines hidden (view full) --- 5077 { 5078 if (globals->use_blx) 5079 { 5080 /* Convert BL to BLX. */ 5081 lower_insn = (lower_insn & ~0x1000) | 0x0800; 5082 } 5083 else if (elf32_thumb_to_arm_stub 5084 (info, sym_name, input_bfd, output_bfd, input_section, |
3410 hit_data, sym_sec, rel->r_offset, signed_addend, value)) | 5085 hit_data, sym_sec, rel->r_offset, signed_addend, value, 5086 error_message)) |
3411 return bfd_reloc_ok; 3412 else 3413 return bfd_reloc_dangerous; 3414 } 3415 else if (sym_flags == STT_ARM_TFUNC && globals->use_blx) 3416 { 3417 /* Make sure this is a BL. */ 3418 lower_insn |= 0x1800; --- 28 unchanged lines hidden (view full) --- 3447 3448 /* If this is a signed value, the rightshift just dropped 3449 leading 1 bits (assuming twos complement). */ 3450 if ((bfd_signed_vma) relocation >= 0) 3451 signed_check = check; 3452 else 3453 signed_check = check | ~((bfd_vma) -1 >> howto->rightshift); 3454 | 5087 return bfd_reloc_ok; 5088 else 5089 return bfd_reloc_dangerous; 5090 } 5091 else if (sym_flags == STT_ARM_TFUNC && globals->use_blx) 5092 { 5093 /* Make sure this is a BL. */ 5094 lower_insn |= 0x1800; --- 28 unchanged lines hidden (view full) --- 5123 5124 /* If this is a signed value, the rightshift just dropped 5125 leading 1 bits (assuming twos complement). */ 5126 if ((bfd_signed_vma) relocation >= 0) 5127 signed_check = check; 5128 else 5129 signed_check = check | ~((bfd_vma) -1 >> howto->rightshift); 5130 |
5131 /* Calculate the permissable maximum and minimum values for 5132 this relocation according to whether we're relocating for 5133 Thumb-2 or not. */ 5134 bitsize = howto->bitsize; 5135 if (!thumb2) 5136 bitsize -= 2; 5137 reloc_signed_max = ((1 << (bitsize - 1)) - 1) >> howto->rightshift; 5138 reloc_signed_min = ~reloc_signed_max; 5139 |
|
3455 /* Assumes two's complement. */ 3456 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) 3457 overflow = TRUE; 3458 3459 if ((lower_insn & 0x1800) == 0x0800) 3460 /* For a BLX instruction, make sure that the relocation is rounded up 3461 to a word boundary. This follows the semantics of the instruction 3462 which specifies that bit 1 of the target address will come from bit 3463 1 of the base address. */ 3464 relocation = (relocation + 2) & ~ 3; 3465 | 5140 /* Assumes two's complement. */ 5141 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) 5142 overflow = TRUE; 5143 5144 if ((lower_insn & 0x1800) == 0x0800) 5145 /* For a BLX instruction, make sure that the relocation is rounded up 5146 to a word boundary. This follows the semantics of the instruction 5147 which specifies that bit 1 of the target address will come from bit 5148 1 of the base address. */ 5149 relocation = (relocation + 2) & ~ 3; 5150 |
3466 /* Put RELOCATION back into the insn. */ 3467 upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 12) & 0x7ff); 3468 lower_insn = (lower_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 1) & 0x7ff); | 5151 /* Put RELOCATION back into the insn. Assumes two's complement. 5152 We use the Thumb-2 encoding, which is safe even if dealing with 5153 a Thumb-1 instruction by virtue of our overflow check above. */ 5154 reloc_sign = (signed_check < 0) ? 1 : 0; 5155 upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) 5156 | ((relocation >> 12) & 0x3ff) 5157 | (reloc_sign << 10); 5158 lower_insn = (lower_insn & ~(bfd_vma) 0x2fff) 5159 | (((!((relocation >> 23) & 1)) ^ reloc_sign) << 13) 5160 | (((!((relocation >> 22) & 1)) ^ reloc_sign) << 11) 5161 | ((relocation >> 1) & 0x7ff); |
3469 3470 /* Put the relocated value back in the object file: */ 3471 bfd_put_16 (input_bfd, upper_insn, hit_data); 3472 bfd_put_16 (input_bfd, lower_insn, hit_data + 2); 3473 3474 return (overflow ? bfd_reloc_overflow : bfd_reloc_ok); 3475 } 3476 break; --- 73 unchanged lines hidden (view full) --- 3550 3551 case R_ARM_THM_JUMP19: 3552 /* Thumb32 conditional branch instruction. */ 3553 { 3554 bfd_vma relocation; 3555 bfd_boolean overflow = FALSE; 3556 bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data); 3557 bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2); | 5162 5163 /* Put the relocated value back in the object file: */ 5164 bfd_put_16 (input_bfd, upper_insn, hit_data); 5165 bfd_put_16 (input_bfd, lower_insn, hit_data + 2); 5166 5167 return (overflow ? bfd_reloc_overflow : bfd_reloc_ok); 5168 } 5169 break; --- 73 unchanged lines hidden (view full) --- 5243 5244 case R_ARM_THM_JUMP19: 5245 /* Thumb32 conditional branch instruction. */ 5246 { 5247 bfd_vma relocation; 5248 bfd_boolean overflow = FALSE; 5249 bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data); 5250 bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2); |
3558 bfd_signed_vma reloc_signed_max = ((1 << (howto->bitsize - 1)) - 1) >> howto->rightshift; 3559 bfd_signed_vma reloc_signed_min = ~ reloc_signed_max; 3560 bfd_vma check; | 5251 bfd_signed_vma reloc_signed_max = 0xffffe; 5252 bfd_signed_vma reloc_signed_min = -0x100000; |
3561 bfd_signed_vma signed_check; 3562 3563 /* Need to refetch the addend, reconstruct the top three bits, 3564 and squish the two 11 bit pieces together. */ 3565 if (globals->use_rel) 3566 { 3567 bfd_vma S = (upper_insn & 0x0400) >> 10; | 5253 bfd_signed_vma signed_check; 5254 5255 /* Need to refetch the addend, reconstruct the top three bits, 5256 and squish the two 11 bit pieces together. */ 5257 if (globals->use_rel) 5258 { 5259 bfd_vma S = (upper_insn & 0x0400) >> 10; |
3568 bfd_vma upper = (upper_insn & 0x001f); | 5260 bfd_vma upper = (upper_insn & 0x003f); |
3569 bfd_vma J1 = (lower_insn & 0x2000) >> 13; 3570 bfd_vma J2 = (lower_insn & 0x0800) >> 11; 3571 bfd_vma lower = (lower_insn & 0x07ff); 3572 | 5261 bfd_vma J1 = (lower_insn & 0x2000) >> 13; 5262 bfd_vma J2 = (lower_insn & 0x0800) >> 11; 5263 bfd_vma lower = (lower_insn & 0x07ff); 5264 |
3573 upper |= J2 << 6; 3574 upper |= J1 << 7; 3575 upper |= ~S << 8; | 5265 upper |= J1 << 6; 5266 upper |= J2 << 7; 5267 upper |= (!S) << 8; |
3576 upper -= 0x0100; /* Sign extend. */ 3577 3578 addend = (upper << 12) | (lower << 1); 3579 signed_addend = addend; 3580 } 3581 3582 /* ??? Should handle interworking? GCC might someday try to 3583 use this for tail calls. */ 3584 3585 relocation = value + signed_addend; 3586 relocation -= (input_section->output_section->vma 3587 + input_section->output_offset 3588 + rel->r_offset); | 5268 upper -= 0x0100; /* Sign extend. */ 5269 5270 addend = (upper << 12) | (lower << 1); 5271 signed_addend = addend; 5272 } 5273 5274 /* ??? Should handle interworking? GCC might someday try to 5275 use this for tail calls. */ 5276 5277 relocation = value + signed_addend; 5278 relocation -= (input_section->output_section->vma 5279 + input_section->output_offset 5280 + rel->r_offset); |
5281 signed_check = (bfd_signed_vma) relocation; |
|
3589 | 5282 |
3590 check = relocation >> howto->rightshift; 3591 3592 /* If this is a signed value, the rightshift just dropped 3593 leading 1 bits (assuming twos complement). */ 3594 if ((bfd_signed_vma) relocation >= 0) 3595 signed_check = check; 3596 else 3597 signed_check = check | ~((bfd_vma) -1 >> howto->rightshift); 3598 3599 /* Assumes two's complement. */ | |
3600 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) 3601 overflow = TRUE; 3602 3603 /* Put RELOCATION back into the insn. */ 3604 { 3605 bfd_vma S = (relocation & 0x00100000) >> 20; 3606 bfd_vma J2 = (relocation & 0x00080000) >> 19; 3607 bfd_vma J1 = (relocation & 0x00040000) >> 18; 3608 bfd_vma hi = (relocation & 0x0003f000) >> 12; 3609 bfd_vma lo = (relocation & 0x00000ffe) >> 1; 3610 | 5283 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) 5284 overflow = TRUE; 5285 5286 /* Put RELOCATION back into the insn. */ 5287 { 5288 bfd_vma S = (relocation & 0x00100000) >> 20; 5289 bfd_vma J2 = (relocation & 0x00080000) >> 19; 5290 bfd_vma J1 = (relocation & 0x00040000) >> 18; 5291 bfd_vma hi = (relocation & 0x0003f000) >> 12; 5292 bfd_vma lo = (relocation & 0x00000ffe) >> 1; 5293 |
3611 upper_insn = (upper_insn & 0xfb30) | (S << 10) | hi; | 5294 upper_insn = (upper_insn & 0xfbc0) | (S << 10) | hi; |
3612 lower_insn = (lower_insn & 0xd000) | (J1 << 13) | (J2 << 11) | lo; 3613 } 3614 3615 /* Put the relocated value back in the object file: */ 3616 bfd_put_16 (input_bfd, upper_insn, hit_data); 3617 bfd_put_16 (input_bfd, lower_insn, hit_data + 2); 3618 3619 return (overflow ? bfd_reloc_overflow : bfd_reloc_ok); --- 472 unchanged lines hidden (view full) --- 4092 /* Preserve Rm (lowest four bits) and the condition code 4093 (highest four bits). Other bits encode MOV PC,Rm. */ 4094 insn = (insn & 0xf000000f) | 0x01a0f000; 4095 4096 bfd_put_32 (input_bfd, insn, hit_data); 4097 } 4098 return bfd_reloc_ok; 4099 | 5295 lower_insn = (lower_insn & 0xd000) | (J1 << 13) | (J2 << 11) | lo; 5296 } 5297 5298 /* Put the relocated value back in the object file: */ 5299 bfd_put_16 (input_bfd, upper_insn, hit_data); 5300 bfd_put_16 (input_bfd, lower_insn, hit_data + 2); 5301 5302 return (overflow ? bfd_reloc_overflow : bfd_reloc_ok); --- 472 unchanged lines hidden (view full) --- 5775 /* Preserve Rm (lowest four bits) and the condition code 5776 (highest four bits). Other bits encode MOV PC,Rm. */ 5777 insn = (insn & 0xf000000f) | 0x01a0f000; 5778 5779 bfd_put_32 (input_bfd, insn, hit_data); 5780 } 5781 return bfd_reloc_ok; 5782 |
4100 default: 4101 return bfd_reloc_notsupported; 4102 } 4103} | 5783 case R_ARM_MOVW_ABS_NC: 5784 case R_ARM_MOVT_ABS: 5785 case R_ARM_MOVW_PREL_NC: 5786 case R_ARM_MOVT_PREL: 5787 /* Until we properly support segment-base-relative addressing then 5788 we assume the segment base to be zero, as for the group relocations. 5789 Thus R_ARM_MOVW_BREL_NC has the same semantics as R_ARM_MOVW_ABS_NC 5790 and R_ARM_MOVT_BREL has the same semantics as R_ARM_MOVT_ABS. */ 5791 case R_ARM_MOVW_BREL_NC: 5792 case R_ARM_MOVW_BREL: 5793 case R_ARM_MOVT_BREL: 5794 { 5795 bfd_vma insn = bfd_get_32 (input_bfd, hit_data); |
4104 | 5796 |
5797 if (globals->use_rel) 5798 { 5799 addend = ((insn >> 4) & 0xf000) | (insn & 0xfff); 5800 signed_addend = (addend ^ 0x10000) - 0x10000; 5801 } |
|
4105 | 5802 |
4106static int 4107uleb128_size (unsigned int i) 4108{ 4109 int size; 4110 size = 1; 4111 while (i >= 0x80) 4112 { 4113 i >>= 7; 4114 size++; 4115 } 4116 return size; 4117} | 5803 value += signed_addend; |
4118 | 5804 |
4119/* Return TRUE if the attribute has the default value (0/""). */ 4120static bfd_boolean 4121is_default_attr (aeabi_attribute *attr) 4122{ 4123 if ((attr->type & 1) && attr->i != 0) 4124 return FALSE; 4125 if ((attr->type & 2) && attr->s && *attr->s) 4126 return FALSE; | 5805 if (r_type == R_ARM_MOVW_PREL_NC || r_type == R_ARM_MOVT_PREL) 5806 value -= (input_section->output_section->vma 5807 + input_section->output_offset + rel->r_offset); |
4127 | 5808 |
4128 return TRUE; 4129} | 5809 if (r_type == R_ARM_MOVW_BREL && value >= 0x10000) 5810 return bfd_reloc_overflow; |
4130 | 5811 |
4131/* Return the size of a single attribute. */ 4132static bfd_vma 4133eabi_attr_size(int tag, aeabi_attribute *attr) 4134{ 4135 bfd_vma size; | 5812 if (sym_flags == STT_ARM_TFUNC) 5813 value |= 1; |
4136 | 5814 |
4137 if (is_default_attr (attr)) 4138 return 0; | 5815 if (r_type == R_ARM_MOVT_ABS || r_type == R_ARM_MOVT_PREL 5816 || r_type == R_ARM_MOVT_BREL) 5817 value >>= 16; |
4139 | 5818 |
4140 size = uleb128_size (tag); 4141 if (attr->type & 1) 4142 size += uleb128_size (attr->i); 4143 if (attr->type & 2) 4144 size += strlen ((char *)attr->s) + 1; 4145 return size; 4146} 4147 4148/* Returns the size of the eabi object attributess section. */ 4149bfd_vma 4150elf32_arm_eabi_attr_size (bfd *abfd) 4151{ 4152 bfd_vma size; 4153 aeabi_attribute *attr; 4154 aeabi_attribute_list *list; 4155 int i; | 5819 insn &= 0xfff0f000; 5820 insn |= value & 0xfff; 5821 insn |= (value & 0xf000) << 4; 5822 bfd_put_32 (input_bfd, insn, hit_data); 5823 } 5824 return bfd_reloc_ok; |
4156 | 5825 |
4157 attr = elf32_arm_tdata (abfd)->known_eabi_attributes; 4158 size = 16; /* 'A' <size> "aeabi" 0x1 <size>. */ 4159 for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) 4160 size += eabi_attr_size (i, &attr[i]); | 5826 case R_ARM_THM_MOVW_ABS_NC: 5827 case R_ARM_THM_MOVT_ABS: 5828 case R_ARM_THM_MOVW_PREL_NC: 5829 case R_ARM_THM_MOVT_PREL: 5830 /* Until we properly support segment-base-relative addressing then 5831 we assume the segment base to be zero, as for the above relocations. 5832 Thus R_ARM_THM_MOVW_BREL_NC has the same semantics as 5833 R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_BREL has the same semantics 5834 as R_ARM_THM_MOVT_ABS. */ 5835 case R_ARM_THM_MOVW_BREL_NC: 5836 case R_ARM_THM_MOVW_BREL: 5837 case R_ARM_THM_MOVT_BREL: 5838 { 5839 bfd_vma insn; 5840 5841 insn = bfd_get_16 (input_bfd, hit_data) << 16; 5842 insn |= bfd_get_16 (input_bfd, hit_data + 2); |
4161 | 5843 |
4162 for (list = elf32_arm_tdata (abfd)->other_eabi_attributes; 4163 list; 4164 list = list->next) 4165 size += eabi_attr_size (list->tag, &list->attr); | 5844 if (globals->use_rel) 5845 { 5846 addend = ((insn >> 4) & 0xf000) 5847 | ((insn >> 15) & 0x0800) 5848 | ((insn >> 4) & 0x0700) 5849 | (insn & 0x00ff); 5850 signed_addend = (addend ^ 0x10000) - 0x10000; 5851 } |
4166 | 5852 |
4167 return size; 4168} | 5853 value += signed_addend; |
4169 | 5854 |
4170static bfd_byte * 4171write_uleb128 (bfd_byte *p, unsigned int val) 4172{ 4173 bfd_byte c; 4174 do 4175 { 4176 c = val & 0x7f; 4177 val >>= 7; 4178 if (val) 4179 c |= 0x80; 4180 *(p++) = c; 4181 } 4182 while (val); 4183 return p; 4184} | 5855 if (r_type == R_ARM_THM_MOVW_PREL_NC || r_type == R_ARM_THM_MOVT_PREL) 5856 value -= (input_section->output_section->vma 5857 + input_section->output_offset + rel->r_offset); |
4185 | 5858 |
4186/* Write attribute ATTR to butter P, and return a pointer to the following 4187 byte. */ 4188static bfd_byte * 4189write_eabi_attribute (bfd_byte *p, int tag, aeabi_attribute *attr) 4190{ 4191 /* Suppress default entries. */ 4192 if (is_default_attr(attr)) 4193 return p; | 5859 if (r_type == R_ARM_THM_MOVW_BREL && value >= 0x10000) 5860 return bfd_reloc_overflow; |
4194 | 5861 |
4195 p = write_uleb128 (p, tag); 4196 if (attr->type & 1) 4197 p = write_uleb128 (p, attr->i); 4198 if (attr->type & 2) 4199 { 4200 int len; | 5862 if (sym_flags == STT_ARM_TFUNC) 5863 value |= 1; |
4201 | 5864 |
4202 len = strlen (attr->s) + 1; 4203 memcpy (p, attr->s, len); 4204 p += len; 4205 } | 5865 if (r_type == R_ARM_THM_MOVT_ABS || r_type == R_ARM_THM_MOVT_PREL 5866 || r_type == R_ARM_THM_MOVT_BREL) 5867 value >>= 16; |
4206 | 5868 |
4207 return p; 4208} | 5869 insn &= 0xfbf08f00; 5870 insn |= (value & 0xf000) << 4; 5871 insn |= (value & 0x0800) << 15; 5872 insn |= (value & 0x0700) << 4; 5873 insn |= (value & 0x00ff); |
4209 | 5874 |
4210/* Write the contents of the eabi attributes section to p. */ 4211void 4212elf32_arm_set_eabi_attr_contents (bfd *abfd, bfd_byte *contents, bfd_vma size) 4213{ 4214 bfd_byte *p; 4215 aeabi_attribute *attr; 4216 aeabi_attribute_list *list; 4217 int i; | 5875 bfd_put_16 (input_bfd, insn >> 16, hit_data); 5876 bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2); 5877 } 5878 return bfd_reloc_ok; |
4218 | 5879 |
4219 p = contents; 4220 *(p++) = 'A'; 4221 bfd_put_32 (abfd, size - 1, p); 4222 p += 4; 4223 memcpy (p, "aeabi", 6); 4224 p += 6; 4225 *(p++) = Tag_File; 4226 bfd_put_32 (abfd, size - 11, p); 4227 p += 4; | 5880 case R_ARM_ALU_PC_G0_NC: 5881 case R_ARM_ALU_PC_G1_NC: 5882 case R_ARM_ALU_PC_G0: 5883 case R_ARM_ALU_PC_G1: 5884 case R_ARM_ALU_PC_G2: 5885 case R_ARM_ALU_SB_G0_NC: 5886 case R_ARM_ALU_SB_G1_NC: 5887 case R_ARM_ALU_SB_G0: 5888 case R_ARM_ALU_SB_G1: 5889 case R_ARM_ALU_SB_G2: 5890 { 5891 bfd_vma insn = bfd_get_32 (input_bfd, hit_data); 5892 bfd_vma pc = input_section->output_section->vma 5893 + input_section->output_offset + rel->r_offset; 5894 /* sb should be the origin of the *segment* containing the symbol. 5895 It is not clear how to obtain this OS-dependent value, so we 5896 make an arbitrary choice of zero. */ 5897 bfd_vma sb = 0; 5898 bfd_vma residual; 5899 bfd_vma g_n; 5900 bfd_signed_vma signed_value; 5901 int group = 0; |
4228 | 5902 |
4229 attr = elf32_arm_tdata (abfd)->known_eabi_attributes; 4230 for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) 4231 p = write_eabi_attribute (p, i, &attr[i]); | 5903 /* Determine which group of bits to select. */ 5904 switch (r_type) 5905 { 5906 case R_ARM_ALU_PC_G0_NC: 5907 case R_ARM_ALU_PC_G0: 5908 case R_ARM_ALU_SB_G0_NC: 5909 case R_ARM_ALU_SB_G0: 5910 group = 0; 5911 break; |
4232 | 5912 |
4233 for (list = elf32_arm_tdata (abfd)->other_eabi_attributes; 4234 list; 4235 list = list->next) 4236 p = write_eabi_attribute (p, list->tag, &list->attr); 4237} | 5913 case R_ARM_ALU_PC_G1_NC: 5914 case R_ARM_ALU_PC_G1: 5915 case R_ARM_ALU_SB_G1_NC: 5916 case R_ARM_ALU_SB_G1: 5917 group = 1; 5918 break; |
4238 | 5919 |
4239/* Override final_link to handle EABI object attribute sections. */ | 5920 case R_ARM_ALU_PC_G2: 5921 case R_ARM_ALU_SB_G2: 5922 group = 2; 5923 break; |
4240 | 5924 |
4241static bfd_boolean 4242elf32_arm_bfd_final_link (bfd *abfd, struct bfd_link_info *info) 4243{ 4244 asection *o; 4245 struct bfd_link_order *p; 4246 asection *attr_section = NULL; 4247 bfd_byte *contents; 4248 bfd_vma size = 0; | 5925 default: 5926 abort(); 5927 } |
4249 | 5928 |
4250 /* elf32_arm_merge_private_bfd_data will already have merged the 4251 object attributes. Remove the input sections from the link, and set 4252 the contents of the output secton. */ 4253 for (o = abfd->sections; o != NULL; o = o->next) 4254 { 4255 if (strcmp (o->name, ".ARM.attributes") == 0) 4256 { 4257 for (p = o->map_head.link_order; p != NULL; p = p->next) 4258 { 4259 asection *input_section; | 5929 /* If REL, extract the addend from the insn. If RELA, it will 5930 have already been fetched for us. */ 5931 if (globals->use_rel) 5932 { 5933 int negative; 5934 bfd_vma constant = insn & 0xff; 5935 bfd_vma rotation = (insn & 0xf00) >> 8; |
4260 | 5936 |
4261 if (p->type != bfd_indirect_link_order) 4262 continue; 4263 input_section = p->u.indirect.section; 4264 /* Hack: reset the SEC_HAS_CONTENTS flag so that 4265 elf_link_input_bfd ignores this section. */ 4266 input_section->flags &= ~SEC_HAS_CONTENTS; 4267 } 4268 4269 size = elf32_arm_eabi_attr_size (abfd); 4270 bfd_set_section_size (abfd, o, size); 4271 attr_section = o; 4272 /* Skip this section later on. */ 4273 o->map_head.link_order = NULL; 4274 } 4275 } 4276 /* Invoke the ELF linker to do all the work. */ 4277 if (!bfd_elf_final_link (abfd, info)) 4278 return FALSE; | 5937 if (rotation == 0) 5938 signed_addend = constant; 5939 else 5940 { 5941 /* Compensate for the fact that in the instruction, the 5942 rotation is stored in multiples of 2 bits. */ 5943 rotation *= 2; |
4279 | 5944 |
4280 if (attr_section) 4281 { 4282 contents = bfd_malloc(size); 4283 if (contents == NULL) 4284 return FALSE; 4285 elf32_arm_set_eabi_attr_contents (abfd, contents, size); 4286 bfd_set_section_contents (abfd, attr_section, contents, 0, size); 4287 free (contents); | 5945 /* Rotate "constant" right by "rotation" bits. */ 5946 signed_addend = (constant >> rotation) | 5947 (constant << (8 * sizeof (bfd_vma) - rotation)); 5948 } 5949 5950 /* Determine if the instruction is an ADD or a SUB. 5951 (For REL, this determines the sign of the addend.) */ 5952 negative = identify_add_or_sub (insn); 5953 if (negative == 0) 5954 { 5955 (*_bfd_error_handler) 5956 (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"), 5957 input_bfd, input_section, 5958 (long) rel->r_offset, howto->name); 5959 return bfd_reloc_overflow; 5960 } 5961 5962 signed_addend *= negative; 5963 } 5964 5965 /* Compute the value (X) to go in the place. */ 5966 if (r_type == R_ARM_ALU_PC_G0_NC 5967 || r_type == R_ARM_ALU_PC_G1_NC 5968 || r_type == R_ARM_ALU_PC_G0 5969 || r_type == R_ARM_ALU_PC_G1 5970 || r_type == R_ARM_ALU_PC_G2) 5971 /* PC relative. */ 5972 signed_value = value - pc + signed_addend; 5973 else 5974 /* Section base relative. */ 5975 signed_value = value - sb + signed_addend; 5976 5977 /* If the target symbol is a Thumb function, then set the 5978 Thumb bit in the address. */ 5979 if (sym_flags == STT_ARM_TFUNC) 5980 signed_value |= 1; 5981 5982 /* Calculate the value of the relevant G_n, in encoded 5983 constant-with-rotation format. */ 5984 g_n = calculate_group_reloc_mask (abs (signed_value), group, 5985 &residual); 5986 5987 /* Check for overflow if required. */ 5988 if ((r_type == R_ARM_ALU_PC_G0 5989 || r_type == R_ARM_ALU_PC_G1 5990 || r_type == R_ARM_ALU_PC_G2 5991 || r_type == R_ARM_ALU_SB_G0 5992 || r_type == R_ARM_ALU_SB_G1 5993 || r_type == R_ARM_ALU_SB_G2) && residual != 0) 5994 { 5995 (*_bfd_error_handler) 5996 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), 5997 input_bfd, input_section, 5998 (long) rel->r_offset, abs (signed_value), howto->name); 5999 return bfd_reloc_overflow; 6000 } 6001 6002 /* Mask out the value and the ADD/SUB part of the opcode; take care 6003 not to destroy the S bit. */ 6004 insn &= 0xff1ff000; 6005 6006 /* Set the opcode according to whether the value to go in the 6007 place is negative. */ 6008 if (signed_value < 0) 6009 insn |= 1 << 22; 6010 else 6011 insn |= 1 << 23; 6012 6013 /* Encode the offset. */ 6014 insn |= g_n; 6015 6016 bfd_put_32 (input_bfd, insn, hit_data); 6017 } 6018 return bfd_reloc_ok; 6019 6020 case R_ARM_LDR_PC_G0: 6021 case R_ARM_LDR_PC_G1: 6022 case R_ARM_LDR_PC_G2: 6023 case R_ARM_LDR_SB_G0: 6024 case R_ARM_LDR_SB_G1: 6025 case R_ARM_LDR_SB_G2: 6026 { 6027 bfd_vma insn = bfd_get_32 (input_bfd, hit_data); 6028 bfd_vma pc = input_section->output_section->vma 6029 + input_section->output_offset + rel->r_offset; 6030 bfd_vma sb = 0; /* See note above. */ 6031 bfd_vma residual; 6032 bfd_signed_vma signed_value; 6033 int group = 0; 6034 6035 /* Determine which groups of bits to calculate. */ 6036 switch (r_type) 6037 { 6038 case R_ARM_LDR_PC_G0: 6039 case R_ARM_LDR_SB_G0: 6040 group = 0; 6041 break; 6042 6043 case R_ARM_LDR_PC_G1: 6044 case R_ARM_LDR_SB_G1: 6045 group = 1; 6046 break; 6047 6048 case R_ARM_LDR_PC_G2: 6049 case R_ARM_LDR_SB_G2: 6050 group = 2; 6051 break; 6052 6053 default: 6054 abort(); 6055 } 6056 6057 /* If REL, extract the addend from the insn. If RELA, it will 6058 have already been fetched for us. */ 6059 if (globals->use_rel) 6060 { 6061 int negative = (insn & (1 << 23)) ? 1 : -1; 6062 signed_addend = negative * (insn & 0xfff); 6063 } 6064 6065 /* Compute the value (X) to go in the place. */ 6066 if (r_type == R_ARM_LDR_PC_G0 6067 || r_type == R_ARM_LDR_PC_G1 6068 || r_type == R_ARM_LDR_PC_G2) 6069 /* PC relative. */ 6070 signed_value = value - pc + signed_addend; 6071 else 6072 /* Section base relative. */ 6073 signed_value = value - sb + signed_addend; 6074 6075 /* Calculate the value of the relevant G_{n-1} to obtain 6076 the residual at that stage. */ 6077 calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); 6078 6079 /* Check for overflow. */ 6080 if (residual >= 0x1000) 6081 { 6082 (*_bfd_error_handler) 6083 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), 6084 input_bfd, input_section, 6085 (long) rel->r_offset, abs (signed_value), howto->name); 6086 return bfd_reloc_overflow; 6087 } 6088 6089 /* Mask out the value and U bit. */ 6090 insn &= 0xff7ff000; 6091 6092 /* Set the U bit if the value to go in the place is non-negative. */ 6093 if (signed_value >= 0) 6094 insn |= 1 << 23; 6095 6096 /* Encode the offset. */ 6097 insn |= residual; 6098 6099 bfd_put_32 (input_bfd, insn, hit_data); 6100 } 6101 return bfd_reloc_ok; 6102 6103 case R_ARM_LDRS_PC_G0: 6104 case R_ARM_LDRS_PC_G1: 6105 case R_ARM_LDRS_PC_G2: 6106 case R_ARM_LDRS_SB_G0: 6107 case R_ARM_LDRS_SB_G1: 6108 case R_ARM_LDRS_SB_G2: 6109 { 6110 bfd_vma insn = bfd_get_32 (input_bfd, hit_data); 6111 bfd_vma pc = input_section->output_section->vma 6112 + input_section->output_offset + rel->r_offset; 6113 bfd_vma sb = 0; /* See note above. */ 6114 bfd_vma residual; 6115 bfd_signed_vma signed_value; 6116 int group = 0; 6117 6118 /* Determine which groups of bits to calculate. */ 6119 switch (r_type) 6120 { 6121 case R_ARM_LDRS_PC_G0: 6122 case R_ARM_LDRS_SB_G0: 6123 group = 0; 6124 break; 6125 6126 case R_ARM_LDRS_PC_G1: 6127 case R_ARM_LDRS_SB_G1: 6128 group = 1; 6129 break; 6130 6131 case R_ARM_LDRS_PC_G2: 6132 case R_ARM_LDRS_SB_G2: 6133 group = 2; 6134 break; 6135 6136 default: 6137 abort(); 6138 } 6139 6140 /* If REL, extract the addend from the insn. If RELA, it will 6141 have already been fetched for us. */ 6142 if (globals->use_rel) 6143 { 6144 int negative = (insn & (1 << 23)) ? 1 : -1; 6145 signed_addend = negative * (((insn & 0xf00) >> 4) + (insn & 0xf)); 6146 } 6147 6148 /* Compute the value (X) to go in the place. */ 6149 if (r_type == R_ARM_LDRS_PC_G0 6150 || r_type == R_ARM_LDRS_PC_G1 6151 || r_type == R_ARM_LDRS_PC_G2) 6152 /* PC relative. */ 6153 signed_value = value - pc + signed_addend; 6154 else 6155 /* Section base relative. */ 6156 signed_value = value - sb + signed_addend; 6157 6158 /* Calculate the value of the relevant G_{n-1} to obtain 6159 the residual at that stage. */ 6160 calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); 6161 6162 /* Check for overflow. */ 6163 if (residual >= 0x100) 6164 { 6165 (*_bfd_error_handler) 6166 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), 6167 input_bfd, input_section, 6168 (long) rel->r_offset, abs (signed_value), howto->name); 6169 return bfd_reloc_overflow; 6170 } 6171 6172 /* Mask out the value and U bit. */ 6173 insn &= 0xff7ff0f0; 6174 6175 /* Set the U bit if the value to go in the place is non-negative. */ 6176 if (signed_value >= 0) 6177 insn |= 1 << 23; 6178 6179 /* Encode the offset. */ 6180 insn |= ((residual & 0xf0) << 4) | (residual & 0xf); 6181 6182 bfd_put_32 (input_bfd, insn, hit_data); 6183 } 6184 return bfd_reloc_ok; 6185 6186 case R_ARM_LDC_PC_G0: 6187 case R_ARM_LDC_PC_G1: 6188 case R_ARM_LDC_PC_G2: 6189 case R_ARM_LDC_SB_G0: 6190 case R_ARM_LDC_SB_G1: 6191 case R_ARM_LDC_SB_G2: 6192 { 6193 bfd_vma insn = bfd_get_32 (input_bfd, hit_data); 6194 bfd_vma pc = input_section->output_section->vma 6195 + input_section->output_offset + rel->r_offset; 6196 bfd_vma sb = 0; /* See note above. */ 6197 bfd_vma residual; 6198 bfd_signed_vma signed_value; 6199 int group = 0; 6200 6201 /* Determine which groups of bits to calculate. */ 6202 switch (r_type) 6203 { 6204 case R_ARM_LDC_PC_G0: 6205 case R_ARM_LDC_SB_G0: 6206 group = 0; 6207 break; 6208 6209 case R_ARM_LDC_PC_G1: 6210 case R_ARM_LDC_SB_G1: 6211 group = 1; 6212 break; 6213 6214 case R_ARM_LDC_PC_G2: 6215 case R_ARM_LDC_SB_G2: 6216 group = 2; 6217 break; 6218 6219 default: 6220 abort(); 6221 } 6222 6223 /* If REL, extract the addend from the insn. If RELA, it will 6224 have already been fetched for us. */ 6225 if (globals->use_rel) 6226 { 6227 int negative = (insn & (1 << 23)) ? 1 : -1; 6228 signed_addend = negative * ((insn & 0xff) << 2); 6229 } 6230 6231 /* Compute the value (X) to go in the place. */ 6232 if (r_type == R_ARM_LDC_PC_G0 6233 || r_type == R_ARM_LDC_PC_G1 6234 || r_type == R_ARM_LDC_PC_G2) 6235 /* PC relative. */ 6236 signed_value = value - pc + signed_addend; 6237 else 6238 /* Section base relative. */ 6239 signed_value = value - sb + signed_addend; 6240 6241 /* Calculate the value of the relevant G_{n-1} to obtain 6242 the residual at that stage. */ 6243 calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); 6244 6245 /* Check for overflow. (The absolute value to go in the place must be 6246 divisible by four and, after having been divided by four, must 6247 fit in eight bits.) */ 6248 if ((residual & 0x3) != 0 || residual >= 0x400) 6249 { 6250 (*_bfd_error_handler) 6251 (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), 6252 input_bfd, input_section, 6253 (long) rel->r_offset, abs (signed_value), howto->name); 6254 return bfd_reloc_overflow; 6255 } 6256 6257 /* Mask out the value and U bit. */ 6258 insn &= 0xff7fff00; 6259 6260 /* Set the U bit if the value to go in the place is non-negative. */ 6261 if (signed_value >= 0) 6262 insn |= 1 << 23; 6263 6264 /* Encode the offset. */ 6265 insn |= residual >> 2; 6266 6267 bfd_put_32 (input_bfd, insn, hit_data); 6268 } 6269 return bfd_reloc_ok; 6270 6271 default: 6272 return bfd_reloc_notsupported; |
4288 } | 6273 } |
4289 return TRUE; | |
4290} 4291 | 6274} 6275 |
4292 | |
4293/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */ 4294static void 4295arm_add_to_rel (bfd * abfd, 4296 bfd_byte * address, 4297 reloc_howto_type * howto, 4298 bfd_signed_vma increment) 4299{ 4300 bfd_signed_vma addend; --- 86 unchanged lines hidden (view full) --- 4387 Elf_Internal_Shdr *symtab_hdr; 4388 struct elf_link_hash_entry **sym_hashes; 4389 Elf_Internal_Rela *rel; 4390 Elf_Internal_Rela *relend; 4391 const char *name; 4392 struct elf32_arm_link_hash_table * globals; 4393 4394 globals = elf32_arm_hash_table (info); | 6276/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */ 6277static void 6278arm_add_to_rel (bfd * abfd, 6279 bfd_byte * address, 6280 reloc_howto_type * howto, 6281 bfd_signed_vma increment) 6282{ 6283 bfd_signed_vma addend; --- 86 unchanged lines hidden (view full) --- 6370 Elf_Internal_Shdr *symtab_hdr; 6371 struct elf_link_hash_entry **sym_hashes; 6372 Elf_Internal_Rela *rel; 6373 Elf_Internal_Rela *relend; 6374 const char *name; 6375 struct elf32_arm_link_hash_table * globals; 6376 6377 globals = elf32_arm_hash_table (info); |
4395 if (info->relocatable && !globals->use_rel) 4396 return TRUE; | |
4397 4398 symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; 4399 sym_hashes = elf_sym_hashes (input_bfd); 4400 4401 rel = relocs; 4402 relend = relocs + input_section->reloc_count; 4403 for (; rel < relend; rel++) 4404 { 4405 int r_type; 4406 reloc_howto_type * howto; 4407 unsigned long r_symndx; 4408 Elf_Internal_Sym * sym; 4409 asection * sec; 4410 struct elf_link_hash_entry * h; 4411 bfd_vma relocation; 4412 bfd_reloc_status_type r; 4413 arelent bfd_reloc; 4414 char sym_type; 4415 bfd_boolean unresolved_reloc = FALSE; | 6378 6379 symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; 6380 sym_hashes = elf_sym_hashes (input_bfd); 6381 6382 rel = relocs; 6383 relend = relocs + input_section->reloc_count; 6384 for (; rel < relend; rel++) 6385 { 6386 int r_type; 6387 reloc_howto_type * howto; 6388 unsigned long r_symndx; 6389 Elf_Internal_Sym * sym; 6390 asection * sec; 6391 struct elf_link_hash_entry * h; 6392 bfd_vma relocation; 6393 bfd_reloc_status_type r; 6394 arelent bfd_reloc; 6395 char sym_type; 6396 bfd_boolean unresolved_reloc = FALSE; |
6397 char *error_message = NULL; |
|
4416 4417 r_symndx = ELF32_R_SYM (rel->r_info); 4418 r_type = ELF32_R_TYPE (rel->r_info); 4419 r_type = arm_real_reloc_type (globals, r_type); 4420 4421 if ( r_type == R_ARM_GNU_VTENTRY 4422 || r_type == R_ARM_GNU_VTINHERIT) 4423 continue; 4424 4425 bfd_reloc.howto = elf32_arm_howto_from_type (r_type); 4426 howto = bfd_reloc.howto; 4427 | 6398 6399 r_symndx = ELF32_R_SYM (rel->r_info); 6400 r_type = ELF32_R_TYPE (rel->r_info); 6401 r_type = arm_real_reloc_type (globals, r_type); 6402 6403 if ( r_type == R_ARM_GNU_VTENTRY 6404 || r_type == R_ARM_GNU_VTINHERIT) 6405 continue; 6406 6407 bfd_reloc.howto = elf32_arm_howto_from_type (r_type); 6408 howto = bfd_reloc.howto; 6409 |
4428 if (info->relocatable && globals->use_rel) 4429 { 4430 /* This is a relocatable link. We don't have to change 4431 anything, unless the reloc is against a section symbol, 4432 in which case we have to adjust according to where the 4433 section symbol winds up in the output section. */ 4434 if (r_symndx < symtab_hdr->sh_info) 4435 { 4436 sym = local_syms + r_symndx; 4437 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) 4438 { 4439 sec = local_sections[r_symndx]; 4440 arm_add_to_rel (input_bfd, contents + rel->r_offset, 4441 howto, 4442 (bfd_signed_vma) (sec->output_offset 4443 + sym->st_value)); 4444 } 4445 } 4446 4447 continue; 4448 } 4449 4450 /* This is a final link. */ | |
4451 h = NULL; 4452 sym = NULL; 4453 sec = NULL; 4454 4455 if (r_symndx < symtab_hdr->sh_info) 4456 { 4457 sym = local_syms + r_symndx; 4458 sym_type = ELF32_ST_TYPE (sym->st_info); 4459 sec = local_sections[r_symndx]; 4460 if (globals->use_rel) 4461 { 4462 relocation = (sec->output_section->vma 4463 + sec->output_offset 4464 + sym->st_value); | 6410 h = NULL; 6411 sym = NULL; 6412 sec = NULL; 6413 6414 if (r_symndx < symtab_hdr->sh_info) 6415 { 6416 sym = local_syms + r_symndx; 6417 sym_type = ELF32_ST_TYPE (sym->st_info); 6418 sec = local_sections[r_symndx]; 6419 if (globals->use_rel) 6420 { 6421 relocation = (sec->output_section->vma 6422 + sec->output_offset 6423 + sym->st_value); |
4465 if ((sec->flags & SEC_MERGE) 4466 && ELF_ST_TYPE (sym->st_info) == STT_SECTION) | 6424 if (!info->relocatable 6425 && (sec->flags & SEC_MERGE) 6426 && ELF_ST_TYPE (sym->st_info) == STT_SECTION) |
4467 { 4468 asection *msec; 4469 bfd_vma addend, value; 4470 4471 if (howto->rightshift) 4472 { 4473 (*_bfd_error_handler) 4474 (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"), --- 33 unchanged lines hidden (view full) --- 4508 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, 4509 r_symndx, symtab_hdr, sym_hashes, 4510 h, sec, relocation, 4511 unresolved_reloc, warned); 4512 4513 sym_type = h->type; 4514 } 4515 | 6427 { 6428 asection *msec; 6429 bfd_vma addend, value; 6430 6431 if (howto->rightshift) 6432 { 6433 (*_bfd_error_handler) 6434 (_("%B(%A+0x%lx): %s relocation against SEC_MERGE section"), --- 33 unchanged lines hidden (view full) --- 6468 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, 6469 r_symndx, symtab_hdr, sym_hashes, 6470 h, sec, relocation, 6471 unresolved_reloc, warned); 6472 6473 sym_type = h->type; 6474 } 6475 |
6476 if (sec != NULL && elf_discarded_section (sec)) 6477 { 6478 /* For relocs against symbols from removed linkonce sections, 6479 or sections discarded by a linker script, we just want the 6480 section contents zeroed. Avoid any special processing. */ 6481 _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); 6482 rel->r_info = 0; 6483 rel->r_addend = 0; 6484 continue; 6485 } 6486 6487 if (info->relocatable) 6488 { 6489 /* This is a relocatable link. We don't have to change 6490 anything, unless the reloc is against a section symbol, 6491 in which case we have to adjust according to where the 6492 section symbol winds up in the output section. */ 6493 if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION) 6494 { 6495 if (globals->use_rel) 6496 arm_add_to_rel (input_bfd, contents + rel->r_offset, 6497 howto, (bfd_signed_vma) sec->output_offset); 6498 else 6499 rel->r_addend += sec->output_offset; 6500 } 6501 continue; 6502 } 6503 |
|
4516 if (h != NULL) 4517 name = h->root.root.string; 4518 else 4519 { 4520 name = (bfd_elf_string_from_elf_section 4521 (input_bfd, symtab_hdr->sh_link, sym->st_name)); 4522 if (name == NULL || *name == '\0') 4523 name = bfd_section_name (input_bfd, sec); --- 17 unchanged lines hidden (view full) --- 4541 name); 4542 } 4543 4544 r = elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 4545 input_section, contents, rel, 4546 relocation, info, sec, name, 4547 (h ? ELF_ST_TYPE (h->type) : 4548 ELF_ST_TYPE (sym->st_info)), h, | 6504 if (h != NULL) 6505 name = h->root.root.string; 6506 else 6507 { 6508 name = (bfd_elf_string_from_elf_section 6509 (input_bfd, symtab_hdr->sh_link, sym->st_name)); 6510 if (name == NULL || *name == '\0') 6511 name = bfd_section_name (input_bfd, sec); --- 17 unchanged lines hidden (view full) --- 6529 name); 6530 } 6531 6532 r = elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 6533 input_section, contents, rel, 6534 relocation, info, sec, name, 6535 (h ? ELF_ST_TYPE (h->type) : 6536 ELF_ST_TYPE (sym->st_info)), h, |
4549 &unresolved_reloc); | 6537 &unresolved_reloc, &error_message); |
4550 4551 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections 4552 because such sections are not SEC_ALLOC and thus ld.so will 4553 not process them. */ 4554 if (unresolved_reloc 4555 && !((input_section->flags & SEC_DEBUGGING) != 0 4556 && h->def_dynamic)) 4557 { --- 4 unchanged lines hidden (view full) --- 4562 (long) rel->r_offset, 4563 howto->name, 4564 h->root.root.string); 4565 return FALSE; 4566 } 4567 4568 if (r != bfd_reloc_ok) 4569 { | 6538 6539 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections 6540 because such sections are not SEC_ALLOC and thus ld.so will 6541 not process them. */ 6542 if (unresolved_reloc 6543 && !((input_section->flags & SEC_DEBUGGING) != 0 6544 && h->def_dynamic)) 6545 { --- 4 unchanged lines hidden (view full) --- 6550 (long) rel->r_offset, 6551 howto->name, 6552 h->root.root.string); 6553 return FALSE; 6554 } 6555 6556 if (r != bfd_reloc_ok) 6557 { |
4570 const char * msg = (const char *) 0; 4571 | |
4572 switch (r) 4573 { 4574 case bfd_reloc_overflow: 4575 /* If the overflowing reloc was to an undefined symbol, 4576 we have already printed one error message and there 4577 is no point complaining again. */ 4578 if ((! h || 4579 h->root.type != bfd_link_hash_undefined) --- 7 unchanged lines hidden (view full) --- 4587 case bfd_reloc_undefined: 4588 if (!((*info->callbacks->undefined_symbol) 4589 (info, name, input_bfd, input_section, 4590 rel->r_offset, TRUE))) 4591 return FALSE; 4592 break; 4593 4594 case bfd_reloc_outofrange: | 6558 switch (r) 6559 { 6560 case bfd_reloc_overflow: 6561 /* If the overflowing reloc was to an undefined symbol, 6562 we have already printed one error message and there 6563 is no point complaining again. */ 6564 if ((! h || 6565 h->root.type != bfd_link_hash_undefined) --- 7 unchanged lines hidden (view full) --- 6573 case bfd_reloc_undefined: 6574 if (!((*info->callbacks->undefined_symbol) 6575 (info, name, input_bfd, input_section, 6576 rel->r_offset, TRUE))) 6577 return FALSE; 6578 break; 6579 6580 case bfd_reloc_outofrange: |
4595 msg = _("internal error: out of range error"); | 6581 error_message = _("out of range"); |
4596 goto common_error; 4597 4598 case bfd_reloc_notsupported: | 6582 goto common_error; 6583 6584 case bfd_reloc_notsupported: |
4599 msg = _("internal error: unsupported relocation error"); | 6585 error_message = _("unsupported relocation"); |
4600 goto common_error; 4601 4602 case bfd_reloc_dangerous: | 6586 goto common_error; 6587 6588 case bfd_reloc_dangerous: |
4603 msg = _("internal error: dangerous error"); | 6589 /* error_message should already be set. */ |
4604 goto common_error; 4605 4606 default: | 6590 goto common_error; 6591 6592 default: |
4607 msg = _("internal error: unknown error"); | 6593 error_message = _("unknown error"); |
4608 /* fall through */ 4609 4610 common_error: | 6594 /* fall through */ 6595 6596 common_error: |
4611 if (!((*info->callbacks->warning) 4612 (info, msg, name, input_bfd, input_section, | 6597 BFD_ASSERT (error_message != NULL); 6598 if (!((*info->callbacks->reloc_dangerous) 6599 (info, error_message, input_bfd, input_section, |
4613 rel->r_offset))) 4614 return FALSE; 4615 break; 4616 } 4617 } 4618 } 4619 4620 return TRUE; 4621} 4622 | 6600 rel->r_offset))) 6601 return FALSE; 6602 break; 6603 } 6604 } 6605 } 6606 6607 return TRUE; 6608} 6609 |
4623/* Allocate/find an object attribute. */ 4624static aeabi_attribute * 4625elf32_arm_new_eabi_attr (bfd *abfd, int tag) 4626{ 4627 aeabi_attribute *attr; 4628 aeabi_attribute_list *list; 4629 aeabi_attribute_list *p; 4630 aeabi_attribute_list **lastp; 4631 4632 4633 if (tag < NUM_KNOWN_ATTRIBUTES) 4634 { 4635 /* Knwon tags are preallocated. */ 4636 attr = &elf32_arm_tdata (abfd)->known_eabi_attributes[tag]; 4637 } 4638 else 4639 { 4640 /* Create a new tag. */ 4641 list = (aeabi_attribute_list *) 4642 bfd_alloc (abfd, sizeof (aeabi_attribute_list)); 4643 memset (list, 0, sizeof (aeabi_attribute_list)); 4644 list->tag = tag; 4645 /* Keep the tag list in order. */ 4646 lastp = &elf32_arm_tdata (abfd)->other_eabi_attributes; 4647 for (p = *lastp; p; p = p->next) 4648 { 4649 if (tag < p->tag) 4650 break; 4651 lastp = &p->next; 4652 } 4653 list->next = *lastp; 4654 *lastp = list; 4655 attr = &list->attr; 4656 } 4657 4658 return attr; 4659} 4660 4661int 4662elf32_arm_get_eabi_attr_int (bfd *abfd, int tag) 4663{ 4664 aeabi_attribute_list *p; 4665 4666 if (tag < NUM_KNOWN_ATTRIBUTES) 4667 { 4668 /* Knwon tags are preallocated. */ 4669 return elf32_arm_tdata (abfd)->known_eabi_attributes[tag].i; 4670 } 4671 else 4672 { 4673 for (p = elf32_arm_tdata (abfd)->other_eabi_attributes; 4674 p; 4675 p = p->next) 4676 { 4677 if (tag == p->tag) 4678 return p->attr.i; 4679 if (tag < p->tag) 4680 break; 4681 } 4682 return 0; 4683 } 4684} 4685 4686void 4687elf32_arm_add_eabi_attr_int (bfd *abfd, int tag, unsigned int i) 4688{ 4689 aeabi_attribute *attr; 4690 4691 attr = elf32_arm_new_eabi_attr (abfd, tag); 4692 attr->type = 1; 4693 attr->i = i; 4694} 4695 4696static char * 4697attr_strdup (bfd *abfd, const char * s) 4698{ 4699 char * p; 4700 int len; 4701 4702 len = strlen (s) + 1; 4703 p = (char *)bfd_alloc(abfd, len); 4704 return memcpy (p, s, len); 4705} 4706 4707void 4708elf32_arm_add_eabi_attr_string (bfd *abfd, int tag, const char *s) 4709{ 4710 aeabi_attribute *attr; 4711 4712 attr = elf32_arm_new_eabi_attr (abfd, tag); 4713 attr->type = 2; 4714 attr->s = attr_strdup (abfd, s); 4715} 4716 4717void 4718elf32_arm_add_eabi_attr_compat (bfd *abfd, unsigned int i, const char *s) 4719{ 4720 aeabi_attribute_list *list; 4721 aeabi_attribute_list *p; 4722 aeabi_attribute_list **lastp; 4723 4724 list = (aeabi_attribute_list *) 4725 bfd_alloc (abfd, sizeof (aeabi_attribute_list)); 4726 memset (list, 0, sizeof (aeabi_attribute_list)); 4727 list->tag = Tag_compatibility; 4728 list->attr.type = 3; 4729 list->attr.i = i; 4730 list->attr.s = attr_strdup (abfd, s); 4731 4732 lastp = &elf32_arm_tdata (abfd)->other_eabi_attributes; 4733 for (p = *lastp; p; p = p->next) 4734 { 4735 int cmp; 4736 if (p->tag != Tag_compatibility) 4737 break; 4738 cmp = strcmp(s, p->attr.s); 4739 if (cmp < 0 || (cmp == 0 && i < p->attr.i)) 4740 break; 4741 lastp = &p->next; 4742 } 4743 list->next = *lastp; 4744 *lastp = list; 4745} 4746 | |
4747/* Set the right machine number. */ 4748 4749static bfd_boolean 4750elf32_arm_object_p (bfd *abfd) 4751{ 4752 unsigned int mach; 4753 4754 mach = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); --- 34 unchanged lines hidden (view full) --- 4789 { 4790 elf_elfheader (abfd)->e_flags = flags; 4791 elf_flags_init (abfd) = TRUE; 4792 } 4793 4794 return TRUE; 4795} 4796 | 6610/* Set the right machine number. */ 6611 6612static bfd_boolean 6613elf32_arm_object_p (bfd *abfd) 6614{ 6615 unsigned int mach; 6616 6617 mach = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION); --- 34 unchanged lines hidden (view full) --- 6652 { 6653 elf_elfheader (abfd)->e_flags = flags; 6654 elf_flags_init (abfd) = TRUE; 6655 } 6656 6657 return TRUE; 6658} 6659 |
4797/* Copy the eabi object attribute from IBFD to OBFD. */ 4798static void 4799copy_eabi_attributes (bfd *ibfd, bfd *obfd) 4800{ 4801 aeabi_attribute *in_attr; 4802 aeabi_attribute *out_attr; 4803 aeabi_attribute_list *list; 4804 int i; 4805 4806 in_attr = elf32_arm_tdata (ibfd)->known_eabi_attributes; 4807 out_attr = elf32_arm_tdata (obfd)->known_eabi_attributes; 4808 for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) 4809 { 4810 out_attr->i = in_attr->i; 4811 if (in_attr->s && *in_attr->s) 4812 out_attr->s = attr_strdup (obfd, in_attr->s); 4813 in_attr++; 4814 out_attr++; 4815 } 4816 4817 for (list = elf32_arm_tdata (ibfd)->other_eabi_attributes; 4818 list; 4819 list = list->next) 4820 { 4821 in_attr = &list->attr; 4822 switch (in_attr->type) 4823 { 4824 case 1: 4825 elf32_arm_add_eabi_attr_int (obfd, list->tag, in_attr->i); 4826 break; 4827 case 2: 4828 elf32_arm_add_eabi_attr_string (obfd, list->tag, in_attr->s); 4829 break; 4830 case 3: 4831 elf32_arm_add_eabi_attr_compat (obfd, in_attr->i, in_attr->s); 4832 break; 4833 default: 4834 abort(); 4835 } 4836 } 4837} 4838 4839 | |
4840/* Copy backend specific data from one object module to another. */ 4841 4842static bfd_boolean 4843elf32_arm_copy_private_bfd_data (bfd *ibfd, bfd *obfd) 4844{ 4845 flagword in_flags; 4846 flagword out_flags; 4847 --- 35 unchanged lines hidden (view full) --- 4883 4884 elf_elfheader (obfd)->e_flags = in_flags; 4885 elf_flags_init (obfd) = TRUE; 4886 4887 /* Also copy the EI_OSABI field. */ 4888 elf_elfheader (obfd)->e_ident[EI_OSABI] = 4889 elf_elfheader (ibfd)->e_ident[EI_OSABI]; 4890 | 6660/* Copy backend specific data from one object module to another. */ 6661 6662static bfd_boolean 6663elf32_arm_copy_private_bfd_data (bfd *ibfd, bfd *obfd) 6664{ 6665 flagword in_flags; 6666 flagword out_flags; 6667 --- 35 unchanged lines hidden (view full) --- 6703 6704 elf_elfheader (obfd)->e_flags = in_flags; 6705 elf_flags_init (obfd) = TRUE; 6706 6707 /* Also copy the EI_OSABI field. */ 6708 elf_elfheader (obfd)->e_ident[EI_OSABI] = 6709 elf_elfheader (ibfd)->e_ident[EI_OSABI]; 6710 |
4891 /* Copy EABI object attributes. */ 4892 copy_eabi_attributes (ibfd, obfd); | 6711 /* Copy object attributes. */ 6712 _bfd_elf_copy_obj_attributes (ibfd, obfd); |
4893 4894 return TRUE; 4895} 4896 4897/* Values for Tag_ABI_PCS_R9_use. */ 4898enum 4899{ 4900 AEABI_R9_V6, --- 15 unchanged lines hidden (view full) --- 4916enum 4917{ 4918 AEABI_enum_unused, 4919 AEABI_enum_short, 4920 AEABI_enum_wide, 4921 AEABI_enum_forced_wide 4922}; 4923 | 6713 6714 return TRUE; 6715} 6716 6717/* Values for Tag_ABI_PCS_R9_use. */ 6718enum 6719{ 6720 AEABI_R9_V6, --- 15 unchanged lines hidden (view full) --- 6736enum 6737{ 6738 AEABI_enum_unused, 6739 AEABI_enum_short, 6740 AEABI_enum_wide, 6741 AEABI_enum_forced_wide 6742}; 6743 |
6744/* Determine whether an object attribute tag takes an integer, a 6745 string or both. */ 6746static int 6747elf32_arm_obj_attrs_arg_type (int tag) 6748{ 6749 if (tag == Tag_compatibility) 6750 return 3; 6751 else if (tag == 4 || tag == 5) 6752 return 2; 6753 else if (tag < 32) 6754 return 1; 6755 else 6756 return (tag & 1) != 0 ? 2 : 1; 6757} 6758 |
|
4924/* Merge EABI object attributes from IBFD into OBFD. Raise an error if there 4925 are conflicting attributes. */ 4926static bfd_boolean 4927elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) 4928{ | 6759/* Merge EABI object attributes from IBFD into OBFD. Raise an error if there 6760 are conflicting attributes. */ 6761static bfd_boolean 6762elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) 6763{ |
4929 aeabi_attribute *in_attr; 4930 aeabi_attribute *out_attr; 4931 aeabi_attribute_list *in_list; 4932 aeabi_attribute_list *out_list; | 6764 obj_attribute *in_attr; 6765 obj_attribute *out_attr; 6766 obj_attribute_list *in_list; |
4933 /* Some tags have 0 = don't care, 1 = strong requirement, 4934 2 = weak requirement. */ 4935 static const int order_312[3] = {3, 1, 2}; 4936 int i; 4937 | 6767 /* Some tags have 0 = don't care, 1 = strong requirement, 6768 2 = weak requirement. */ 6769 static const int order_312[3] = {3, 1, 2}; 6770 int i; 6771 |
4938 if (!elf32_arm_tdata (ibfd)->known_eabi_attributes[0].i) | 6772 if (!elf_known_obj_attributes_proc (obfd)[0].i) |
4939 { 4940 /* This is the first object. Copy the attributes. */ | 6773 { 6774 /* This is the first object. Copy the attributes. */ |
4941 copy_eabi_attributes (ibfd, obfd); | 6775 _bfd_elf_copy_obj_attributes (ibfd, obfd); 6776 6777 /* Use the Tag_null value to indicate the attributes have been 6778 initialized. */ 6779 elf_known_obj_attributes_proc (obfd)[0].i = 1; 6780 |
4942 return TRUE; 4943 } 4944 | 6781 return TRUE; 6782 } 6783 |
4945 /* Use the Tag_null value to indicate the attributes have been 4946 initialized. */ 4947 elf32_arm_tdata (ibfd)->known_eabi_attributes[0].i = 1; 4948 4949 in_attr = elf32_arm_tdata (ibfd)->known_eabi_attributes; 4950 out_attr = elf32_arm_tdata (obfd)->known_eabi_attributes; | 6784 in_attr = elf_known_obj_attributes_proc (ibfd); 6785 out_attr = elf_known_obj_attributes_proc (obfd); |
4951 /* This needs to happen before Tag_ABI_FP_number_model is merged. */ 4952 if (in_attr[Tag_ABI_VFP_args].i != out_attr[Tag_ABI_VFP_args].i) 4953 { 4954 /* Ignore mismatches if teh object doesn't use floating point. */ 4955 if (out_attr[Tag_ABI_FP_number_model].i == 0) 4956 out_attr[Tag_ABI_VFP_args].i = in_attr[Tag_ABI_VFP_args].i; 4957 else if (in_attr[Tag_ABI_FP_number_model].i != 0) 4958 { 4959 _bfd_error_handler 4960 (_("ERROR: %B uses VFP register arguments, %B does not"), 4961 ibfd, obfd); 4962 return FALSE; 4963 } 4964 } 4965 | 6786 /* This needs to happen before Tag_ABI_FP_number_model is merged. */ 6787 if (in_attr[Tag_ABI_VFP_args].i != out_attr[Tag_ABI_VFP_args].i) 6788 { 6789 /* Ignore mismatches if teh object doesn't use floating point. */ 6790 if (out_attr[Tag_ABI_FP_number_model].i == 0) 6791 out_attr[Tag_ABI_VFP_args].i = in_attr[Tag_ABI_VFP_args].i; 6792 else if (in_attr[Tag_ABI_FP_number_model].i != 0) 6793 { 6794 _bfd_error_handler 6795 (_("ERROR: %B uses VFP register arguments, %B does not"), 6796 ibfd, obfd); 6797 return FALSE; 6798 } 6799 } 6800 |
4966 for (i = 4; i < NUM_KNOWN_ATTRIBUTES; i++) | 6801 for (i = 4; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++) |
4967 { 4968 /* Merge this attribute with existing attributes. */ 4969 switch (i) 4970 { 4971 case Tag_CPU_raw_name: 4972 case Tag_CPU_name: | 6802 { 6803 /* Merge this attribute with existing attributes. */ 6804 switch (i) 6805 { 6806 case Tag_CPU_raw_name: 6807 case Tag_CPU_name: |
4973 /* Use whichever has the greatest architecture requirements. */ 4974 if (in_attr[Tag_CPU_arch].i > out_attr[Tag_CPU_arch].i) 4975 out_attr[i].s = attr_strdup(obfd, in_attr[i].s); | 6808 /* Use whichever has the greatest architecture requirements. We 6809 won't necessarily have both the above tags, so make sure input 6810 name is non-NULL. */ 6811 if (in_attr[Tag_CPU_arch].i > out_attr[Tag_CPU_arch].i 6812 && in_attr[i].s) 6813 out_attr[i].s = _bfd_elf_attr_strdup (obfd, in_attr[i].s); |
4976 break; 4977 4978 case Tag_ABI_optimization_goals: 4979 case Tag_ABI_FP_optimization_goals: 4980 /* Use the first value seen. */ 4981 break; 4982 4983 case Tag_CPU_arch: --- 34 unchanged lines hidden (view full) --- 5018 { 5019 /* It's sometimes ok to mix different configs, so this is only 5020 a warning. */ 5021 _bfd_error_handler 5022 (_("Warning: %B: Conflicting platform configuration"), ibfd); 5023 } 5024 break; 5025 case Tag_ABI_PCS_R9_use: | 6814 break; 6815 6816 case Tag_ABI_optimization_goals: 6817 case Tag_ABI_FP_optimization_goals: 6818 /* Use the first value seen. */ 6819 break; 6820 6821 case Tag_CPU_arch: --- 34 unchanged lines hidden (view full) --- 6856 { 6857 /* It's sometimes ok to mix different configs, so this is only 6858 a warning. */ 6859 _bfd_error_handler 6860 (_("Warning: %B: Conflicting platform configuration"), ibfd); 6861 } 6862 break; 6863 case Tag_ABI_PCS_R9_use: |
5026 if (out_attr[i].i != AEABI_R9_unused | 6864 if (in_attr[i].i != out_attr[i].i 6865 && out_attr[i].i != AEABI_R9_unused |
5027 && in_attr[i].i != AEABI_R9_unused) 5028 { 5029 _bfd_error_handler 5030 (_("ERROR: %B: Conflicting use of R9"), ibfd); 5031 return FALSE; 5032 } 5033 if (out_attr[i].i == AEABI_R9_unused) 5034 out_attr[i].i = in_attr[i].i; --- 44 unchanged lines hidden (view full) --- 5079 if (out_attr[i].i == AEABI_enum_unused 5080 || out_attr[i].i == AEABI_enum_forced_wide) 5081 { 5082 /* The existing object is compatible with anything. 5083 Use whatever requirements the new object has. */ 5084 out_attr[i].i = in_attr[i].i; 5085 } 5086 else if (in_attr[i].i != AEABI_enum_forced_wide | 6866 && in_attr[i].i != AEABI_R9_unused) 6867 { 6868 _bfd_error_handler 6869 (_("ERROR: %B: Conflicting use of R9"), ibfd); 6870 return FALSE; 6871 } 6872 if (out_attr[i].i == AEABI_R9_unused) 6873 out_attr[i].i = in_attr[i].i; --- 44 unchanged lines hidden (view full) --- 6918 if (out_attr[i].i == AEABI_enum_unused 6919 || out_attr[i].i == AEABI_enum_forced_wide) 6920 { 6921 /* The existing object is compatible with anything. 6922 Use whatever requirements the new object has. */ 6923 out_attr[i].i = in_attr[i].i; 6924 } 6925 else if (in_attr[i].i != AEABI_enum_forced_wide |
5087 && out_attr[i].i != in_attr[i].i) | 6926 && out_attr[i].i != in_attr[i].i 6927 && !elf32_arm_tdata (obfd)->no_enum_size_warning) |
5088 { | 6928 { |
6929 const char *aeabi_enum_names[] = 6930 { "", "variable-size", "32-bit", "" }; |
|
5089 _bfd_error_handler | 6931 _bfd_error_handler |
5090 (_("ERROR: %B: Conflicting enum sizes"), ibfd); | 6932 (_("warning: %B uses %s enums yet the output is to use %s enums; use of enum values across objects may fail"), 6933 ibfd, aeabi_enum_names[in_attr[i].i], 6934 aeabi_enum_names[out_attr[i].i]); |
5091 } 5092 } 5093 break; 5094 case Tag_ABI_VFP_args: 5095 /* Aready done. */ 5096 break; 5097 case Tag_ABI_WMMX_args: 5098 if (in_attr[i].i != out_attr[i].i) --- 4 unchanged lines hidden (view full) --- 5103 return FALSE; 5104 } 5105 break; 5106 default: /* All known attributes should be explicitly covered. */ 5107 abort (); 5108 } 5109 } 5110 | 6935 } 6936 } 6937 break; 6938 case Tag_ABI_VFP_args: 6939 /* Aready done. */ 6940 break; 6941 case Tag_ABI_WMMX_args: 6942 if (in_attr[i].i != out_attr[i].i) --- 4 unchanged lines hidden (view full) --- 6947 return FALSE; 6948 } 6949 break; 6950 default: /* All known attributes should be explicitly covered. */ 6951 abort (); 6952 } 6953 } 6954 |
5111 in_list = elf32_arm_tdata (ibfd)->other_eabi_attributes; 5112 out_list = elf32_arm_tdata (ibfd)->other_eabi_attributes; | 6955 /* Merge Tag_compatibility attributes and any common GNU ones. */ 6956 _bfd_elf_merge_object_attributes (ibfd, obfd); 6957 6958 /* Check for any attributes not known on ARM. */ 6959 in_list = elf_other_obj_attributes_proc (ibfd); |
5113 while (in_list && in_list->tag == Tag_compatibility) | 6960 while (in_list && in_list->tag == Tag_compatibility) |
5114 { 5115 in_attr = &in_list->attr; 5116 if (in_attr->i == 0) 5117 continue; 5118 if (in_attr->i == 1) 5119 { 5120 _bfd_error_handler 5121 (_("ERROR: %B: Must be processed by '%s' toolchain"), 5122 ibfd, in_attr->s); 5123 return FALSE; 5124 } 5125 if (!out_list || out_list->tag != Tag_compatibility 5126 || strcmp (in_attr->s, out_list->attr.s) != 0) 5127 { 5128 /* Add this compatibility tag to the output. */ 5129 elf32_arm_add_eabi_attr_compat (obfd, in_attr->i, in_attr->s); 5130 continue; 5131 } 5132 out_attr = &out_list->attr; 5133 /* Check all the input tags with the same identifier. */ 5134 for (;;) 5135 { 5136 if (out_list->tag != Tag_compatibility 5137 || in_attr->i != out_attr->i 5138 || strcmp (in_attr->s, out_attr->s) != 0) 5139 { 5140 _bfd_error_handler 5141 (_("ERROR: %B: Incompatible object tag '%s':%d"), 5142 ibfd, in_attr->s, in_attr->i); 5143 return FALSE; 5144 } 5145 in_list = in_list->next; 5146 if (in_list->tag != Tag_compatibility 5147 || strcmp (in_attr->s, in_list->attr.s) != 0) 5148 break; 5149 in_attr = &in_list->attr; 5150 out_list = out_list->next; 5151 if (out_list) 5152 out_attr = &out_list->attr; 5153 } | 6961 in_list = in_list->next; |
5154 | 6962 |
5155 /* Check the output doesn't have extra tags with this identifier. */ 5156 if (out_list && out_list->tag == Tag_compatibility 5157 && strcmp (in_attr->s, out_list->attr.s) == 0) 5158 { 5159 _bfd_error_handler 5160 (_("ERROR: %B: Incompatible object tag '%s':%d"), 5161 ibfd, in_attr->s, out_list->attr.i); 5162 return FALSE; 5163 } 5164 } 5165 | |
5166 for (; in_list; in_list = in_list->next) 5167 { 5168 if ((in_list->tag & 128) < 64) 5169 { 5170 _bfd_error_handler 5171 (_("Warning: %B: Unknown EABI object attribute %d"), 5172 ibfd, in_list->tag); 5173 break; --- 384 unchanged lines hidden (view full) --- 5558 default: 5559 break; 5560 } 5561 5562 return type; 5563} 5564 5565static asection * | 6963 for (; in_list; in_list = in_list->next) 6964 { 6965 if ((in_list->tag & 128) < 64) 6966 { 6967 _bfd_error_handler 6968 (_("Warning: %B: Unknown EABI object attribute %d"), 6969 ibfd, in_list->tag); 6970 break; --- 384 unchanged lines hidden (view full) --- 7355 default: 7356 break; 7357 } 7358 7359 return type; 7360} 7361 7362static asection * |
5566elf32_arm_gc_mark_hook (asection * sec, 5567 struct bfd_link_info * info ATTRIBUTE_UNUSED, 5568 Elf_Internal_Rela * rel, 5569 struct elf_link_hash_entry * h, 5570 Elf_Internal_Sym * sym) | 7363elf32_arm_gc_mark_hook (asection *sec, 7364 struct bfd_link_info *info, 7365 Elf_Internal_Rela *rel, 7366 struct elf_link_hash_entry *h, 7367 Elf_Internal_Sym *sym) |
5571{ 5572 if (h != NULL) | 7368{ 7369 if (h != NULL) |
5573 { 5574 switch (ELF32_R_TYPE (rel->r_info)) | 7370 switch (ELF32_R_TYPE (rel->r_info)) |
5575 { 5576 case R_ARM_GNU_VTINHERIT: 5577 case R_ARM_GNU_VTENTRY: | 7371 { 7372 case R_ARM_GNU_VTINHERIT: 7373 case R_ARM_GNU_VTENTRY: |
5578 break; | 7374 return NULL; 7375 } |
5579 | 7376 |
5580 default: 5581 switch (h->root.type) 5582 { 5583 case bfd_link_hash_defined: 5584 case bfd_link_hash_defweak: 5585 return h->root.u.def.section; 5586 5587 case bfd_link_hash_common: 5588 return h->root.u.c.p->section; 5589 5590 default: 5591 break; 5592 } 5593 } 5594 } 5595 else 5596 return bfd_section_from_elf_index (sec->owner, sym->st_shndx); 5597 5598 return NULL; | 7377 return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); |
5599} 5600 5601/* Update the got entry reference counts for the section being removed. */ 5602 5603static bfd_boolean 5604elf32_arm_gc_sweep_hook (bfd * abfd, 5605 struct bfd_link_info * info, 5606 asection * sec, --- 49 unchanged lines hidden (view full) --- 5656 } 5657 break; 5658 5659 case R_ARM_TLS_LDM32: 5660 elf32_arm_hash_table (info)->tls_ldm_got.refcount -= 1; 5661 break; 5662 5663 case R_ARM_ABS32: | 7378} 7379 7380/* Update the got entry reference counts for the section being removed. */ 7381 7382static bfd_boolean 7383elf32_arm_gc_sweep_hook (bfd * abfd, 7384 struct bfd_link_info * info, 7385 asection * sec, --- 49 unchanged lines hidden (view full) --- 7435 } 7436 break; 7437 7438 case R_ARM_TLS_LDM32: 7439 elf32_arm_hash_table (info)->tls_ldm_got.refcount -= 1; 7440 break; 7441 7442 case R_ARM_ABS32: |
7443 case R_ARM_ABS32_NOI: |
|
5664 case R_ARM_REL32: | 7444 case R_ARM_REL32: |
7445 case R_ARM_REL32_NOI: |
|
5665 case R_ARM_PC24: 5666 case R_ARM_PLT32: 5667 case R_ARM_CALL: 5668 case R_ARM_JUMP24: 5669 case R_ARM_PREL31: 5670 case R_ARM_THM_CALL: | 7446 case R_ARM_PC24: 7447 case R_ARM_PLT32: 7448 case R_ARM_CALL: 7449 case R_ARM_JUMP24: 7450 case R_ARM_PREL31: 7451 case R_ARM_THM_CALL: |
7452 case R_ARM_MOVW_ABS_NC: 7453 case R_ARM_MOVT_ABS: 7454 case R_ARM_MOVW_PREL_NC: 7455 case R_ARM_MOVT_PREL: 7456 case R_ARM_THM_MOVW_ABS_NC: 7457 case R_ARM_THM_MOVT_ABS: 7458 case R_ARM_THM_MOVW_PREL_NC: 7459 case R_ARM_THM_MOVT_PREL: |
|
5671 /* Should the interworking branches be here also? */ 5672 5673 if (h != NULL) 5674 { 5675 struct elf32_arm_link_hash_entry *eh; 5676 struct elf32_arm_relocs_copied **pp; 5677 struct elf32_arm_relocs_copied *p; 5678 5679 eh = (struct elf32_arm_link_hash_entry *) h; 5680 5681 if (h->plt.refcount > 0) 5682 { 5683 h->plt.refcount -= 1; 5684 if (ELF32_R_TYPE (rel->r_info) == R_ARM_THM_CALL) 5685 eh->plt_thumb_refcount--; 5686 } 5687 5688 if (r_type == R_ARM_ABS32 | 7460 /* Should the interworking branches be here also? */ 7461 7462 if (h != NULL) 7463 { 7464 struct elf32_arm_link_hash_entry *eh; 7465 struct elf32_arm_relocs_copied **pp; 7466 struct elf32_arm_relocs_copied *p; 7467 7468 eh = (struct elf32_arm_link_hash_entry *) h; 7469 7470 if (h->plt.refcount > 0) 7471 { 7472 h->plt.refcount -= 1; 7473 if (ELF32_R_TYPE (rel->r_info) == R_ARM_THM_CALL) 7474 eh->plt_thumb_refcount--; 7475 } 7476 7477 if (r_type == R_ARM_ABS32 |
5689 || r_type == R_ARM_REL32) | 7478 || r_type == R_ARM_REL32 7479 || r_type == R_ARM_ABS32_NOI 7480 || r_type == R_ARM_REL32_NOI) |
5690 { 5691 for (pp = &eh->relocs_copied; (p = *pp) != NULL; 5692 pp = &p->next) 5693 if (p->section == sec) 5694 { 5695 p->count -= 1; | 7481 { 7482 for (pp = &eh->relocs_copied; (p = *pp) != NULL; 7483 pp = &p->next) 7484 if (p->section == sec) 7485 { 7486 p->count -= 1; |
5696 if (ELF32_R_TYPE (rel->r_info) == R_ARM_REL32) | 7487 if (ELF32_R_TYPE (rel->r_info) == R_ARM_REL32 7488 || ELF32_R_TYPE (rel->r_info) == R_ARM_REL32_NOI) |
5697 p->pc_count -= 1; 5698 if (p->count == 0) 5699 *pp = p->next; 5700 break; 5701 } 5702 } 5703 } 5704 break; --- 161 unchanged lines hidden (view full) --- 5866 case R_ARM_ABS12: 5867 /* VxWorks uses dynamic R_ARM_ABS12 relocations for 5868 ldr __GOTT_INDEX__ offsets. */ 5869 if (!htab->vxworks_p) 5870 break; 5871 /* Fall through */ 5872 5873 case R_ARM_ABS32: | 7489 p->pc_count -= 1; 7490 if (p->count == 0) 7491 *pp = p->next; 7492 break; 7493 } 7494 } 7495 } 7496 break; --- 161 unchanged lines hidden (view full) --- 7658 case R_ARM_ABS12: 7659 /* VxWorks uses dynamic R_ARM_ABS12 relocations for 7660 ldr __GOTT_INDEX__ offsets. */ 7661 if (!htab->vxworks_p) 7662 break; 7663 /* Fall through */ 7664 7665 case R_ARM_ABS32: |
7666 case R_ARM_ABS32_NOI: |
|
5874 case R_ARM_REL32: | 7667 case R_ARM_REL32: |
7668 case R_ARM_REL32_NOI: |
|
5875 case R_ARM_PC24: 5876 case R_ARM_PLT32: 5877 case R_ARM_CALL: 5878 case R_ARM_JUMP24: 5879 case R_ARM_PREL31: 5880 case R_ARM_THM_CALL: | 7669 case R_ARM_PC24: 7670 case R_ARM_PLT32: 7671 case R_ARM_CALL: 7672 case R_ARM_JUMP24: 7673 case R_ARM_PREL31: 7674 case R_ARM_THM_CALL: |
7675 case R_ARM_MOVW_ABS_NC: 7676 case R_ARM_MOVT_ABS: 7677 case R_ARM_MOVW_PREL_NC: 7678 case R_ARM_MOVT_PREL: 7679 case R_ARM_THM_MOVW_ABS_NC: 7680 case R_ARM_THM_MOVT_ABS: 7681 case R_ARM_THM_MOVW_PREL_NC: 7682 case R_ARM_THM_MOVT_PREL: |
|
5881 /* Should the interworking branches be listed here? */ 5882 if (h != NULL) 5883 { 5884 /* If this reloc is in a read-only section, we might 5885 need a copy reloc. We can't check reliably at this 5886 stage whether the section is read-only, as input 5887 sections have not yet been mapped to output sections. 5888 Tentatively set the flag for now, and correct in 5889 adjust_dynamic_symbol. */ 5890 if (!info->shared) 5891 h->non_got_ref = 1; 5892 5893 /* We may need a .plt entry if the function this reloc 5894 refers to is in a different object. We can't tell for 5895 sure yet, because something later might force the 5896 symbol local. */ | 7683 /* Should the interworking branches be listed here? */ 7684 if (h != NULL) 7685 { 7686 /* If this reloc is in a read-only section, we might 7687 need a copy reloc. We can't check reliably at this 7688 stage whether the section is read-only, as input 7689 sections have not yet been mapped to output sections. 7690 Tentatively set the flag for now, and correct in 7691 adjust_dynamic_symbol. */ 7692 if (!info->shared) 7693 h->non_got_ref = 1; 7694 7695 /* We may need a .plt entry if the function this reloc 7696 refers to is in a different object. We can't tell for 7697 sure yet, because something later might force the 7698 symbol local. */ |
5897 if (r_type == R_ARM_PC24 5898 || r_type == R_ARM_CALL 5899 || r_type == R_ARM_JUMP24 5900 || r_type == R_ARM_PREL31 5901 || r_type == R_ARM_PLT32 5902 || r_type == R_ARM_THM_CALL) | 7699 if (r_type != R_ARM_ABS32 7700 && r_type != R_ARM_REL32 7701 && r_type != R_ARM_ABS32_NOI 7702 && r_type != R_ARM_REL32_NOI 7703 && r_type != R_ARM_ABS12) |
5903 h->needs_plt = 1; 5904 5905 /* If we create a PLT entry, this relocation will reference 5906 it, even if it's an ABS32 relocation. */ 5907 h->plt.refcount += 1; 5908 5909 if (r_type == R_ARM_THM_CALL) 5910 eh->plt_thumb_refcount += 1; --- 8 unchanged lines hidden (view full) --- 5919 including in the link (i.e., DEF_REGULAR is set). At 5920 this point we have not seen all the input files, so it is 5921 possible that DEF_REGULAR is not set now but will be set 5922 later (it is never cleared). We account for that 5923 possibility below by storing information in the 5924 relocs_copied field of the hash table entry. */ 5925 if ((info->shared || htab->root.is_relocatable_executable) 5926 && (sec->flags & SEC_ALLOC) != 0 | 7704 h->needs_plt = 1; 7705 7706 /* If we create a PLT entry, this relocation will reference 7707 it, even if it's an ABS32 relocation. */ 7708 h->plt.refcount += 1; 7709 7710 if (r_type == R_ARM_THM_CALL) 7711 eh->plt_thumb_refcount += 1; --- 8 unchanged lines hidden (view full) --- 7720 including in the link (i.e., DEF_REGULAR is set). At 7721 this point we have not seen all the input files, so it is 7722 possible that DEF_REGULAR is not set now but will be set 7723 later (it is never cleared). We account for that 7724 possibility below by storing information in the 7725 relocs_copied field of the hash table entry. */ 7726 if ((info->shared || htab->root.is_relocatable_executable) 7727 && (sec->flags & SEC_ALLOC) != 0 |
5927 && (r_type == R_ARM_ABS32 | 7728 && ((r_type == R_ARM_ABS32 || r_type == R_ARM_ABS32_NOI) |
5928 || (h != NULL && ! h->needs_plt 5929 && (! info->symbolic || ! h->def_regular)))) 5930 { 5931 struct elf32_arm_relocs_copied *p, **head; 5932 5933 /* When creating a shared object, we must copy these 5934 reloc types into the output file. We create a reloc 5935 section in dynobj and make room for this reloc. */ --- 67 unchanged lines hidden (view full) --- 6003 return FALSE; 6004 p->next = *head; 6005 *head = p; 6006 p->section = sec; 6007 p->count = 0; 6008 p->pc_count = 0; 6009 } 6010 | 7729 || (h != NULL && ! h->needs_plt 7730 && (! info->symbolic || ! h->def_regular)))) 7731 { 7732 struct elf32_arm_relocs_copied *p, **head; 7733 7734 /* When creating a shared object, we must copy these 7735 reloc types into the output file. We create a reloc 7736 section in dynobj and make room for this reloc. */ --- 67 unchanged lines hidden (view full) --- 7804 return FALSE; 7805 p->next = *head; 7806 *head = p; 7807 p->section = sec; 7808 p->count = 0; 7809 p->pc_count = 0; 7810 } 7811 |
6011 if (r_type == R_ARM_REL32) | 7812 if (r_type == R_ARM_REL32 || r_type == R_ARM_REL32_NOI) |
6012 p->pc_count += 1; 6013 p->count += 1; 6014 } 6015 break; 6016 6017 /* This relocation describes the C++ object vtable hierarchy. 6018 Reconstruct it for later use during GC. */ 6019 case R_ARM_GNU_VTINHERIT: --- 8 unchanged lines hidden (view full) --- 6028 return FALSE; 6029 break; 6030 } 6031 } 6032 6033 return TRUE; 6034} 6035 | 7813 p->pc_count += 1; 7814 p->count += 1; 7815 } 7816 break; 7817 7818 /* This relocation describes the C++ object vtable hierarchy. 7819 Reconstruct it for later use during GC. */ 7820 case R_ARM_GNU_VTINHERIT: --- 8 unchanged lines hidden (view full) --- 7829 return FALSE; 7830 break; 7831 } 7832 } 7833 7834 return TRUE; 7835} 7836 |
7837/* Unwinding tables are not referenced directly. This pass marks them as 7838 required if the corresponding code section is marked. */ 7839 7840static bfd_boolean 7841elf32_arm_gc_mark_extra_sections(struct bfd_link_info *info, 7842 elf_gc_mark_hook_fn gc_mark_hook) 7843{ 7844 bfd *sub; 7845 Elf_Internal_Shdr **elf_shdrp; 7846 bfd_boolean again; 7847 7848 /* Marking EH data may cause additional code sections to be marked, 7849 requiring multiple passes. */ 7850 again = TRUE; 7851 while (again) 7852 { 7853 again = FALSE; 7854 for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) 7855 { 7856 asection *o; 7857 7858 if (bfd_get_flavour (sub) != bfd_target_elf_flavour) 7859 continue; 7860 7861 elf_shdrp = elf_elfsections (sub); 7862 for (o = sub->sections; o != NULL; o = o->next) 7863 { 7864 Elf_Internal_Shdr *hdr; 7865 hdr = &elf_section_data (o)->this_hdr; 7866 if (hdr->sh_type == SHT_ARM_EXIDX && hdr->sh_link 7867 && !o->gc_mark 7868 && elf_shdrp[hdr->sh_link]->bfd_section->gc_mark) 7869 { 7870 again = TRUE; 7871 if (!_bfd_elf_gc_mark (info, o, gc_mark_hook)) 7872 return FALSE; 7873 } 7874 } 7875 } 7876 } 7877 7878 return TRUE; 7879} 7880 |
|
6036/* Treat mapping symbols as special target symbols. */ 6037 6038static bfd_boolean 6039elf32_arm_is_target_special_symbol (bfd * abfd ATTRIBUTE_UNUSED, asymbol * sym) 6040{ | 7881/* Treat mapping symbols as special target symbols. */ 7882 7883static bfd_boolean 7884elf32_arm_is_target_special_symbol (bfd * abfd ATTRIBUTE_UNUSED, asymbol * sym) 7885{ |
6041 return bfd_is_arm_mapping_symbol_name (sym->name); | 7886 return bfd_is_arm_special_symbol_name (sym->name, 7887 BFD_ARM_SPECIAL_SYM_TYPE_ANY); |
6042} 6043 6044/* This is a copy of elf_find_function() from elf.c except that 6045 ARM mapping symbols are ignored when looking for function names 6046 and STT_ARM_TFUNC is considered to a function type. */ 6047 6048static bfd_boolean 6049arm_elf_find_function (bfd * abfd ATTRIBUTE_UNUSED, --- 19 unchanged lines hidden (view full) --- 6069 default: 6070 break; 6071 case STT_FILE: 6072 filename = bfd_asymbol_name (&q->symbol); 6073 break; 6074 case STT_FUNC: 6075 case STT_ARM_TFUNC: 6076 case STT_NOTYPE: | 7888} 7889 7890/* This is a copy of elf_find_function() from elf.c except that 7891 ARM mapping symbols are ignored when looking for function names 7892 and STT_ARM_TFUNC is considered to a function type. */ 7893 7894static bfd_boolean 7895arm_elf_find_function (bfd * abfd ATTRIBUTE_UNUSED, --- 19 unchanged lines hidden (view full) --- 7915 default: 7916 break; 7917 case STT_FILE: 7918 filename = bfd_asymbol_name (&q->symbol); 7919 break; 7920 case STT_FUNC: 7921 case STT_ARM_TFUNC: 7922 case STT_NOTYPE: |
6077 /* Skip $a and $t symbols. */ | 7923 /* Skip mapping symbols. */ |
6078 if ((q->symbol.flags & BSF_LOCAL) | 7924 if ((q->symbol.flags & BSF_LOCAL) |
6079 && bfd_is_arm_mapping_symbol_name (q->symbol.name)) | 7925 && bfd_is_arm_special_symbol_name (q->symbol.name, 7926 BFD_ARM_SPECIAL_SYM_TYPE_ANY)) |
6080 continue; 6081 /* Fall through. */ 6082 if (bfd_get_section (&q->symbol) == section 6083 && q->symbol.value >= low_func 6084 && q->symbol.value <= offset) 6085 { 6086 func = (asymbol *) q; 6087 low_func = q->symbol.value; --- 84 unchanged lines hidden (view full) --- 6172 understand. */ 6173 6174static bfd_boolean 6175elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, 6176 struct elf_link_hash_entry * h) 6177{ 6178 bfd * dynobj; 6179 asection * s; | 7927 continue; 7928 /* Fall through. */ 7929 if (bfd_get_section (&q->symbol) == section 7930 && q->symbol.value >= low_func 7931 && q->symbol.value <= offset) 7932 { 7933 func = (asymbol *) q; 7934 low_func = q->symbol.value; --- 84 unchanged lines hidden (view full) --- 8019 understand. */ 8020 8021static bfd_boolean 8022elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, 8023 struct elf_link_hash_entry * h) 8024{ 8025 bfd * dynobj; 8026 asection * s; |
6180 unsigned int power_of_two; | |
6181 struct elf32_arm_link_hash_entry * eh; 6182 struct elf32_arm_link_hash_table *globals; 6183 6184 globals = elf32_arm_hash_table (info); 6185 dynobj = elf_hash_table (info)->dynobj; 6186 6187 /* Make sure we know what is going on here. */ 6188 BFD_ASSERT (dynobj != NULL --- 96 unchanged lines hidden (view full) --- 6285 asection *srel; 6286 6287 srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (globals, ".bss")); 6288 BFD_ASSERT (srel != NULL); 6289 srel->size += RELOC_SIZE (globals); 6290 h->needs_copy = 1; 6291 } 6292 | 8027 struct elf32_arm_link_hash_entry * eh; 8028 struct elf32_arm_link_hash_table *globals; 8029 8030 globals = elf32_arm_hash_table (info); 8031 dynobj = elf_hash_table (info)->dynobj; 8032 8033 /* Make sure we know what is going on here. */ 8034 BFD_ASSERT (dynobj != NULL --- 96 unchanged lines hidden (view full) --- 8131 asection *srel; 8132 8133 srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (globals, ".bss")); 8134 BFD_ASSERT (srel != NULL); 8135 srel->size += RELOC_SIZE (globals); 8136 h->needs_copy = 1; 8137 } 8138 |
6293 /* We need to figure out the alignment required for this symbol. I 6294 have no idea how ELF linkers handle this. */ 6295 power_of_two = bfd_log2 (h->size); 6296 if (power_of_two > 3) 6297 power_of_two = 3; 6298 6299 /* Apply the required alignment. */ 6300 s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); 6301 if (power_of_two > bfd_get_section_alignment (dynobj, s)) 6302 { 6303 if (! bfd_set_section_alignment (dynobj, s, power_of_two)) 6304 return FALSE; 6305 } 6306 6307 /* Define the symbol as being at this point in the section. */ 6308 h->root.u.def.section = s; 6309 h->root.u.def.value = s->size; 6310 6311 /* Increment the section size to make room for the symbol. */ 6312 s->size += h->size; 6313 6314 return TRUE; | 8139 return _bfd_elf_adjust_dynamic_copy (h, s); |
6315} 6316 6317/* Allocate space in .plt, .got and associated reloc sections for 6318 dynamic relocs. */ 6319 6320static bfd_boolean 6321allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) 6322{ --- 172 unchanged lines hidden (view full) --- 6495 && (info->shared 6496 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) 6497 htab->srelgot->size += RELOC_SIZE (htab); 6498 } 6499 } 6500 else 6501 h->got.offset = (bfd_vma) -1; 6502 | 8140} 8141 8142/* Allocate space in .plt, .got and associated reloc sections for 8143 dynamic relocs. */ 8144 8145static bfd_boolean 8146allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) 8147{ --- 172 unchanged lines hidden (view full) --- 8320 && (info->shared 8321 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) 8322 htab->srelgot->size += RELOC_SIZE (htab); 8323 } 8324 } 8325 else 8326 h->got.offset = (bfd_vma) -1; 8327 |
8328 /* Allocate stubs for exported Thumb functions on v4t. */ 8329 if (!htab->use_blx && h->dynindx != -1 8330 && h->def_regular 8331 && ELF_ST_TYPE (h->type) == STT_ARM_TFUNC 8332 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) 8333 { 8334 struct elf_link_hash_entry * th; 8335 struct bfd_link_hash_entry * bh; 8336 struct elf_link_hash_entry * myh; 8337 char name[1024]; 8338 asection *s; 8339 bh = NULL; 8340 /* Create a new symbol to regist the real location of the function. */ 8341 s = h->root.u.def.section; 8342 sprintf(name, "__real_%s", h->root.root.string); 8343 _bfd_generic_link_add_one_symbol (info, s->owner, 8344 name, BSF_GLOBAL, s, 8345 h->root.u.def.value, 8346 NULL, TRUE, FALSE, &bh); 8347 8348 myh = (struct elf_link_hash_entry *) bh; 8349 myh->type = ELF_ST_INFO (STB_LOCAL, STT_ARM_TFUNC); 8350 myh->forced_local = 1; 8351 eh->export_glue = myh; 8352 th = record_arm_to_thumb_glue (info, h); 8353 /* Point the symbol at the stub. */ 8354 h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC); 8355 h->root.u.def.section = th->root.u.def.section; 8356 h->root.u.def.value = th->root.u.def.value & ~1; 8357 } 8358 |
|
6503 if (eh->relocs_copied == NULL) 6504 return TRUE; 6505 6506 /* In the shared -Bsymbolic case, discard space allocated for 6507 dynamic pc-relative relocs against symbols which turn out to be 6508 defined in regular objects. For the normal shared case, discard 6509 space for pc-relative relocs that have become local due to symbol 6510 visibility changes. */ 6511 6512 if (info->shared || htab->root.is_relocatable_executable) 6513 { | 8359 if (eh->relocs_copied == NULL) 8360 return TRUE; 8361 8362 /* In the shared -Bsymbolic case, discard space allocated for 8363 dynamic pc-relative relocs against symbols which turn out to be 8364 defined in regular objects. For the normal shared case, discard 8365 space for pc-relative relocs that have become local due to symbol 8366 visibility changes. */ 8367 8368 if (info->shared || htab->root.is_relocatable_executable) 8369 { |
6514 /* The only reloc that uses pc_count is R_ARM_REL32, which will 6515 appear on something like ".long foo - .". We want calls to 6516 protected symbols to resolve directly to the function rather 6517 than going via the plt. If people want function pointer 6518 comparisons to work as expected then they should avoid 6519 writing assembly like ".long foo - .". */ | 8370 /* The only relocs that use pc_count are R_ARM_REL32 and 8371 R_ARM_REL32_NOI, which will appear on something like 8372 ".long foo - .". We want calls to protected symbols to resolve 8373 directly to the function rather than going via the plt. If people 8374 want function pointer comparisons to work as expected then they 8375 should avoid writing assembly like ".long foo - .". */ |
6520 if (SYMBOL_CALLS_LOCAL (info, h)) 6521 { 6522 struct elf32_arm_relocs_copied **pp; 6523 6524 for (pp = &eh->relocs_copied; (p = *pp) != NULL; ) 6525 { 6526 p->count -= p->pc_count; 6527 p->pc_count = 0; --- 100 unchanged lines hidden (view full) --- 6628 6629 /* Not an error, just cut short the traversal. */ 6630 return FALSE; 6631 } 6632 } 6633 return TRUE; 6634} 6635 | 8376 if (SYMBOL_CALLS_LOCAL (info, h)) 8377 { 8378 struct elf32_arm_relocs_copied **pp; 8379 8380 for (pp = &eh->relocs_copied; (p = *pp) != NULL; ) 8381 { 8382 p->count -= p->pc_count; 8383 p->pc_count = 0; --- 100 unchanged lines hidden (view full) --- 8484 8485 /* Not an error, just cut short the traversal. */ 8486 return FALSE; 8487 } 8488 } 8489 return TRUE; 8490} 8491 |
8492void 8493bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *info, 8494 int byteswap_code) 8495{ 8496 struct elf32_arm_link_hash_table *globals; 8497 8498 globals = elf32_arm_hash_table (info); 8499 globals->byteswap_code = byteswap_code; 8500} 8501 |
|
6636/* Set the sizes of the dynamic sections. */ 6637 6638static bfd_boolean 6639elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, 6640 struct bfd_link_info * info) 6641{ 6642 bfd * dynobj; 6643 asection * s; --- 99 unchanged lines hidden (view full) --- 6743 } 6744 else 6745 htab->tls_ldm_got.offset = -1; 6746 6747 /* Allocate global sym .plt and .got entries, and space for global 6748 sym dynamic relocs. */ 6749 elf_link_hash_traverse (& htab->root, allocate_dynrelocs, info); 6750 | 8502/* Set the sizes of the dynamic sections. */ 8503 8504static bfd_boolean 8505elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, 8506 struct bfd_link_info * info) 8507{ 8508 bfd * dynobj; 8509 asection * s; --- 99 unchanged lines hidden (view full) --- 8609 } 8610 else 8611 htab->tls_ldm_got.offset = -1; 8612 8613 /* Allocate global sym .plt and .got entries, and space for global 8614 sym dynamic relocs. */ 8615 elf_link_hash_traverse (& htab->root, allocate_dynrelocs, info); 8616 |
8617 /* Here we rummage through the found bfds to collect glue information. */ 8618 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) 8619 { 8620 /* Initialise mapping tables for code/data. */ 8621 bfd_elf32_arm_init_maps (ibfd); 8622 8623 if (!bfd_elf32_arm_process_before_allocation (ibfd, info) 8624 || !bfd_elf32_arm_vfp11_erratum_scan (ibfd, info)) 8625 /* xgettext:c-format */ 8626 _bfd_error_handler (_("Errors encountered processing file %s"), 8627 ibfd->filename); 8628 } 8629 |
|
6751 /* The check_relocs and adjust_dynamic_symbol entry points have 6752 determined the sizes of the various dynamic sections. Allocate 6753 memory for them. */ 6754 plt = FALSE; 6755 relocs = FALSE; 6756 for (s = dynobj->sections; s != NULL; s = s->next) 6757 { 6758 const char * name; --- 5 unchanged lines hidden (view full) --- 6764 of the dynobj section names depend upon the input files. */ 6765 name = bfd_get_section_name (dynobj, s); 6766 6767 if (strcmp (name, ".plt") == 0) 6768 { 6769 /* Remember whether there is a PLT. */ 6770 plt = s->size != 0; 6771 } | 8630 /* The check_relocs and adjust_dynamic_symbol entry points have 8631 determined the sizes of the various dynamic sections. Allocate 8632 memory for them. */ 8633 plt = FALSE; 8634 relocs = FALSE; 8635 for (s = dynobj->sections; s != NULL; s = s->next) 8636 { 8637 const char * name; --- 5 unchanged lines hidden (view full) --- 8643 of the dynobj section names depend upon the input files. */ 8644 name = bfd_get_section_name (dynobj, s); 8645 8646 if (strcmp (name, ".plt") == 0) 8647 { 8648 /* Remember whether there is a PLT. */ 8649 plt = s->size != 0; 8650 } |
6772 else if (strncmp (name, ".rel", 4) == 0) | 8651 else if (CONST_STRNEQ (name, ".rel")) |
6773 { 6774 if (s->size != 0) 6775 { 6776 /* Remember whether there are any reloc sections other 6777 than .rel(a).plt and .rela.plt.unloaded. */ 6778 if (s != htab->srelplt && s != htab->srelplt2) 6779 relocs = TRUE; 6780 6781 /* We use the reloc_count field as a counter if we need 6782 to copy relocs into the output file. */ 6783 s->reloc_count = 0; 6784 } 6785 } | 8652 { 8653 if (s->size != 0) 8654 { 8655 /* Remember whether there are any reloc sections other 8656 than .rel(a).plt and .rela.plt.unloaded. */ 8657 if (s != htab->srelplt && s != htab->srelplt2) 8658 relocs = TRUE; 8659 8660 /* We use the reloc_count field as a counter if we need 8661 to copy relocs into the output file. */ 8662 s->reloc_count = 0; 8663 } 8664 } |
6786 else if (strncmp (name, ".got", 4) != 0 | 8665 else if (! CONST_STRNEQ (name, ".got") |
6787 && strcmp (name, ".dynbss") != 0) 6788 { 6789 /* It's not one of our sections, so don't allocate space. */ 6790 continue; 6791 } 6792 6793 if (s->size == 0) 6794 { --- 110 unchanged lines hidden (view full) --- 6905 6906 splt = bfd_get_section_by_name (dynobj, ".plt"); 6907 srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".plt")); 6908 BFD_ASSERT (splt != NULL && srel != NULL); 6909 6910 /* Fill in the entry in the procedure linkage table. */ 6911 if (htab->symbian_p) 6912 { | 8666 && strcmp (name, ".dynbss") != 0) 8667 { 8668 /* It's not one of our sections, so don't allocate space. */ 8669 continue; 8670 } 8671 8672 if (s->size == 0) 8673 { --- 110 unchanged lines hidden (view full) --- 8784 8785 splt = bfd_get_section_by_name (dynobj, ".plt"); 8786 srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".plt")); 8787 BFD_ASSERT (splt != NULL && srel != NULL); 8788 8789 /* Fill in the entry in the procedure linkage table. */ 8790 if (htab->symbian_p) 8791 { |
6913 unsigned i; 6914 for (i = 0; i < htab->plt_entry_size / 4; ++i) 6915 bfd_put_32 (output_bfd, 6916 elf32_arm_symbian_plt_entry[i], 6917 splt->contents + h->plt.offset + 4 * i); | 8792 put_arm_insn (htab, output_bfd, 8793 elf32_arm_symbian_plt_entry[0], 8794 splt->contents + h->plt.offset); 8795 bfd_put_32 (output_bfd, 8796 elf32_arm_symbian_plt_entry[1], 8797 splt->contents + h->plt.offset + 4); |
6918 6919 /* Fill in the entry in the .rel.plt section. */ 6920 rel.r_offset = (splt->output_section->vma 6921 + splt->output_offset | 8798 8799 /* Fill in the entry in the .rel.plt section. */ 8800 rel.r_offset = (splt->output_section->vma 8801 + splt->output_offset |
6922 + h->plt.offset + 4 * (i - 1)); | 8802 + h->plt.offset + 4); |
6923 rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT); 6924 6925 /* Get the index in the procedure linkage table which 6926 corresponds to this symbol. This is the index of this symbol 6927 in all the symbols for which we are making plt entries. The 6928 first entry in the procedure linkage table is reserved. */ 6929 plt_index = ((h->plt.offset - htab->plt_header_size) 6930 / htab->plt_entry_size); 6931 } 6932 else 6933 { 6934 bfd_vma got_offset, got_address, plt_address; 6935 bfd_vma got_displacement; 6936 asection * sgot; | 8803 rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT); 8804 8805 /* Get the index in the procedure linkage table which 8806 corresponds to this symbol. This is the index of this symbol 8807 in all the symbols for which we are making plt entries. The 8808 first entry in the procedure linkage table is reserved. */ 8809 plt_index = ((h->plt.offset - htab->plt_header_size) 8810 / htab->plt_entry_size); 8811 } 8812 else 8813 { 8814 bfd_vma got_offset, got_address, plt_address; 8815 bfd_vma got_displacement; 8816 asection * sgot; |
8817 bfd_byte * ptr; |
|
6937 6938 sgot = bfd_get_section_by_name (dynobj, ".got.plt"); 6939 BFD_ASSERT (sgot != NULL); 6940 6941 /* Get the offset into the .got.plt table of the entry that 6942 corresponds to this function. */ 6943 got_offset = eh->plt_got_offset; 6944 --- 9 unchanged lines hidden (view full) --- 6954 + sgot->output_offset 6955 + got_offset); 6956 6957 /* ...and the address of the PLT entry. */ 6958 plt_address = (splt->output_section->vma 6959 + splt->output_offset 6960 + h->plt.offset); 6961 | 8818 8819 sgot = bfd_get_section_by_name (dynobj, ".got.plt"); 8820 BFD_ASSERT (sgot != NULL); 8821 8822 /* Get the offset into the .got.plt table of the entry that 8823 corresponds to this function. */ 8824 got_offset = eh->plt_got_offset; 8825 --- 9 unchanged lines hidden (view full) --- 8835 + sgot->output_offset 8836 + got_offset); 8837 8838 /* ...and the address of the PLT entry. */ 8839 plt_address = (splt->output_section->vma 8840 + splt->output_offset 8841 + h->plt.offset); 8842 |
8843 ptr = htab->splt->contents + h->plt.offset; |
|
6962 if (htab->vxworks_p && info->shared) 6963 { 6964 unsigned int i; 6965 bfd_vma val; 6966 | 8844 if (htab->vxworks_p && info->shared) 8845 { 8846 unsigned int i; 8847 bfd_vma val; 8848 |
6967 for (i = 0; i != htab->plt_entry_size / 4; i++) | 8849 for (i = 0; i != htab->plt_entry_size / 4; i++, ptr += 4) |
6968 { 6969 val = elf32_arm_vxworks_shared_plt_entry[i]; 6970 if (i == 2) 6971 val |= got_address - sgot->output_section->vma; 6972 if (i == 5) 6973 val |= plt_index * RELOC_SIZE (htab); | 8850 { 8851 val = elf32_arm_vxworks_shared_plt_entry[i]; 8852 if (i == 2) 8853 val |= got_address - sgot->output_section->vma; 8854 if (i == 5) 8855 val |= plt_index * RELOC_SIZE (htab); |
6974 bfd_put_32 (output_bfd, val, 6975 htab->splt->contents + h->plt.offset + i * 4); | 8856 if (i == 2 || i == 5) 8857 bfd_put_32 (output_bfd, val, ptr); 8858 else 8859 put_arm_insn (htab, output_bfd, val, ptr); |
6976 } 6977 } 6978 else if (htab->vxworks_p) 6979 { 6980 unsigned int i; 6981 bfd_vma val; 6982 | 8860 } 8861 } 8862 else if (htab->vxworks_p) 8863 { 8864 unsigned int i; 8865 bfd_vma val; 8866 |
6983 for (i = 0; i != htab->plt_entry_size / 4; i++) | 8867 for (i = 0; i != htab->plt_entry_size / 4; i++, ptr += 4) |
6984 { 6985 val = elf32_arm_vxworks_exec_plt_entry[i]; 6986 if (i == 2) 6987 val |= got_address; 6988 if (i == 4) 6989 val |= 0xffffff & -((h->plt.offset + i * 4 + 8) >> 2); 6990 if (i == 5) 6991 val |= plt_index * RELOC_SIZE (htab); | 8868 { 8869 val = elf32_arm_vxworks_exec_plt_entry[i]; 8870 if (i == 2) 8871 val |= got_address; 8872 if (i == 4) 8873 val |= 0xffffff & -((h->plt.offset + i * 4 + 8) >> 2); 8874 if (i == 5) 8875 val |= plt_index * RELOC_SIZE (htab); |
6992 bfd_put_32 (output_bfd, val, 6993 htab->splt->contents + h->plt.offset + i * 4); | 8876 if (i == 2 || i == 5) 8877 bfd_put_32 (output_bfd, val, ptr); 8878 else 8879 put_arm_insn (htab, output_bfd, val, ptr); |
6994 } 6995 6996 loc = (htab->srelplt2->contents 6997 + (plt_index * 2 + 1) * RELOC_SIZE (htab)); 6998 6999 /* Create the .rela.plt.unloaded R_ARM_ABS32 relocation 7000 referencing the GOT for this PLT entry. */ 7001 rel.r_offset = plt_address + 8; --- 16 unchanged lines hidden (view full) --- 7018 value produced by adding to pc in the first instruction 7019 of the PLT stub. */ 7020 got_displacement = got_address - (plt_address + 8); 7021 7022 BFD_ASSERT ((got_displacement & 0xf0000000) == 0); 7023 7024 if (!htab->use_blx && eh->plt_thumb_refcount > 0) 7025 { | 8880 } 8881 8882 loc = (htab->srelplt2->contents 8883 + (plt_index * 2 + 1) * RELOC_SIZE (htab)); 8884 8885 /* Create the .rela.plt.unloaded R_ARM_ABS32 relocation 8886 referencing the GOT for this PLT entry. */ 8887 rel.r_offset = plt_address + 8; --- 16 unchanged lines hidden (view full) --- 8904 value produced by adding to pc in the first instruction 8905 of the PLT stub. */ 8906 got_displacement = got_address - (plt_address + 8); 8907 8908 BFD_ASSERT ((got_displacement & 0xf0000000) == 0); 8909 8910 if (!htab->use_blx && eh->plt_thumb_refcount > 0) 8911 { |
7026 bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[0], 7027 splt->contents + h->plt.offset - 4); 7028 bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[1], 7029 splt->contents + h->plt.offset - 2); | 8912 put_thumb_insn (htab, output_bfd, 8913 elf32_arm_plt_thumb_stub[0], ptr - 4); 8914 put_thumb_insn (htab, output_bfd, 8915 elf32_arm_plt_thumb_stub[1], ptr - 2); |
7030 } 7031 | 8916 } 8917 |
7032 bfd_put_32 (output_bfd, 7033 elf32_arm_plt_entry[0] 7034 | ((got_displacement & 0x0ff00000) >> 20), 7035 splt->contents + h->plt.offset + 0); 7036 bfd_put_32 (output_bfd, 7037 elf32_arm_plt_entry[1] 7038 | ((got_displacement & 0x000ff000) >> 12), 7039 splt->contents + h->plt.offset + 4); 7040 bfd_put_32 (output_bfd, 7041 elf32_arm_plt_entry[2] 7042 | (got_displacement & 0x00000fff), 7043 splt->contents + h->plt.offset + 8); | 8918 put_arm_insn (htab, output_bfd, 8919 elf32_arm_plt_entry[0] 8920 | ((got_displacement & 0x0ff00000) >> 20), 8921 ptr + 0); 8922 put_arm_insn (htab, output_bfd, 8923 elf32_arm_plt_entry[1] 8924 | ((got_displacement & 0x000ff000) >> 12), 8925 ptr+ 4); 8926 put_arm_insn (htab, output_bfd, 8927 elf32_arm_plt_entry[2] 8928 | (got_displacement & 0x00000fff), 8929 ptr + 8); |
7044#ifdef FOUR_WORD_PLT | 8930#ifdef FOUR_WORD_PLT |
7045 bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], 7046 splt->contents + h->plt.offset + 12); | 8931 bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12); |
7047#endif 7048 } 7049 7050 /* Fill in the entry in the global offset table. */ 7051 bfd_put_32 (output_bfd, 7052 (splt->output_section->vma 7053 + splt->output_offset), 7054 sgot->contents + got_offset); --- 293 unchanged lines hidden (view full) --- 7348 if (htab->vxworks_p) 7349 { 7350 /* The VxWorks GOT is relocated by the dynamic linker. 7351 Therefore, we must emit relocations rather than simply 7352 computing the values now. */ 7353 Elf_Internal_Rela rel; 7354 7355 plt0_entry = elf32_arm_vxworks_exec_plt0_entry; | 8932#endif 8933 } 8934 8935 /* Fill in the entry in the global offset table. */ 8936 bfd_put_32 (output_bfd, 8937 (splt->output_section->vma 8938 + splt->output_offset), 8939 sgot->contents + got_offset); --- 293 unchanged lines hidden (view full) --- 9233 if (htab->vxworks_p) 9234 { 9235 /* The VxWorks GOT is relocated by the dynamic linker. 9236 Therefore, we must emit relocations rather than simply 9237 computing the values now. */ 9238 Elf_Internal_Rela rel; 9239 9240 plt0_entry = elf32_arm_vxworks_exec_plt0_entry; |
7356 bfd_put_32 (output_bfd, plt0_entry[0], splt->contents + 0); 7357 bfd_put_32 (output_bfd, plt0_entry[1], splt->contents + 4); 7358 bfd_put_32 (output_bfd, plt0_entry[2], splt->contents + 8); | 9241 put_arm_insn (htab, output_bfd, plt0_entry[0], 9242 splt->contents + 0); 9243 put_arm_insn (htab, output_bfd, plt0_entry[1], 9244 splt->contents + 4); 9245 put_arm_insn (htab, output_bfd, plt0_entry[2], 9246 splt->contents + 8); |
7359 bfd_put_32 (output_bfd, got_address, splt->contents + 12); 7360 7361 /* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */ 7362 rel.r_offset = plt_address + 12; 7363 rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); 7364 rel.r_addend = 0; 7365 SWAP_RELOC_OUT (htab) (output_bfd, &rel, 7366 htab->srelplt2->contents); 7367 } 7368 else 7369 { 7370 got_displacement = got_address - (plt_address + 16); 7371 7372 plt0_entry = elf32_arm_plt0_entry; | 9247 bfd_put_32 (output_bfd, got_address, splt->contents + 12); 9248 9249 /* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */ 9250 rel.r_offset = plt_address + 12; 9251 rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); 9252 rel.r_addend = 0; 9253 SWAP_RELOC_OUT (htab) (output_bfd, &rel, 9254 htab->srelplt2->contents); 9255 } 9256 else 9257 { 9258 got_displacement = got_address - (plt_address + 16); 9259 9260 plt0_entry = elf32_arm_plt0_entry; |
7373 bfd_put_32 (output_bfd, plt0_entry[0], splt->contents + 0); 7374 bfd_put_32 (output_bfd, plt0_entry[1], splt->contents + 4); 7375 bfd_put_32 (output_bfd, plt0_entry[2], splt->contents + 8); 7376 bfd_put_32 (output_bfd, plt0_entry[3], splt->contents + 12); | 9261 put_arm_insn (htab, output_bfd, plt0_entry[0], 9262 splt->contents + 0); 9263 put_arm_insn (htab, output_bfd, plt0_entry[1], 9264 splt->contents + 4); 9265 put_arm_insn (htab, output_bfd, plt0_entry[2], 9266 splt->contents + 8); 9267 put_arm_insn (htab, output_bfd, plt0_entry[3], 9268 splt->contents + 12); |
7377 7378#ifdef FOUR_WORD_PLT 7379 /* The displacement value goes in the otherwise-unused 7380 last word of the second entry. */ 7381 bfd_put_32 (output_bfd, got_displacement, splt->contents + 28); 7382#else 7383 bfd_put_32 (output_bfd, got_displacement, splt->contents + 16); 7384#endif 7385 } 7386 } 7387 7388 /* UnixWare sets the entsize of .plt to 4, although that doesn't 7389 really seem like the right value. */ | 9269 9270#ifdef FOUR_WORD_PLT 9271 /* The displacement value goes in the otherwise-unused 9272 last word of the second entry. */ 9273 bfd_put_32 (output_bfd, got_displacement, splt->contents + 28); 9274#else 9275 bfd_put_32 (output_bfd, got_displacement, splt->contents + 16); 9276#endif 9277 } 9278 } 9279 9280 /* UnixWare sets the entsize of .plt to 4, although that doesn't 9281 really seem like the right value. */ |
7390 elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; | 9282 if (splt->output_section->owner == output_bfd) 9283 elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; |
7391 7392 if (htab->vxworks_p && !info->shared && htab->splt->size > 0) 7393 { 7394 /* Correct the .rel(a).plt.unloaded relocations. They will have 7395 incorrect symbol indexes. */ 7396 int num_plts; 7397 unsigned char *p; 7398 --- 94 unchanged lines hidden (view full) --- 7493 bfd_arm_update_notes (abfd, ARM_NOTE_SECTION); 7494} 7495 7496/* Return TRUE if this is an unwinding table entry. */ 7497 7498static bfd_boolean 7499is_arm_elf_unwind_section_name (bfd * abfd ATTRIBUTE_UNUSED, const char * name) 7500{ | 9284 9285 if (htab->vxworks_p && !info->shared && htab->splt->size > 0) 9286 { 9287 /* Correct the .rel(a).plt.unloaded relocations. They will have 9288 incorrect symbol indexes. */ 9289 int num_plts; 9290 unsigned char *p; 9291 --- 94 unchanged lines hidden (view full) --- 9386 bfd_arm_update_notes (abfd, ARM_NOTE_SECTION); 9387} 9388 9389/* Return TRUE if this is an unwinding table entry. */ 9390 9391static bfd_boolean 9392is_arm_elf_unwind_section_name (bfd * abfd ATTRIBUTE_UNUSED, const char * name) 9393{ |
7501 size_t len1, len2; 7502 7503 len1 = sizeof (ELF_STRING_ARM_unwind) - 1; 7504 len2 = sizeof (ELF_STRING_ARM_unwind_once) - 1; 7505 return (strncmp (name, ELF_STRING_ARM_unwind, len1) == 0 7506 || strncmp (name, ELF_STRING_ARM_unwind_once, len2) == 0); | 9394 return (CONST_STRNEQ (name, ELF_STRING_ARM_unwind) 9395 || CONST_STRNEQ (name, ELF_STRING_ARM_unwind_once)); |
7507} 7508 7509 7510/* Set the type and flags for an ARM section. We do this by 7511 the section name, which is a hack, but ought to work. */ 7512 7513static bfd_boolean 7514elf32_arm_fake_sections (bfd * abfd, Elf_Internal_Shdr * hdr, asection * sec) 7515{ 7516 const char * name; 7517 7518 name = bfd_get_section_name (abfd, sec); 7519 7520 if (is_arm_elf_unwind_section_name (abfd, name)) 7521 { 7522 hdr->sh_type = SHT_ARM_EXIDX; 7523 hdr->sh_flags |= SHF_LINK_ORDER; 7524 } | 9396} 9397 9398 9399/* Set the type and flags for an ARM section. We do this by 9400 the section name, which is a hack, but ought to work. */ 9401 9402static bfd_boolean 9403elf32_arm_fake_sections (bfd * abfd, Elf_Internal_Shdr * hdr, asection * sec) 9404{ 9405 const char * name; 9406 9407 name = bfd_get_section_name (abfd, sec); 9408 9409 if (is_arm_elf_unwind_section_name (abfd, name)) 9410 { 9411 hdr->sh_type = SHT_ARM_EXIDX; 9412 hdr->sh_flags |= SHF_LINK_ORDER; 9413 } |
7525 else if (strcmp(name, ".ARM.attributes") == 0) 7526 { 7527 hdr->sh_type = SHT_ARM_ATTRIBUTES; 7528 } | |
7529 return TRUE; 7530} 7531 | 9414 return TRUE; 9415} 9416 |
7532/* Parse an Arm EABI attributes section. */ 7533static void 7534elf32_arm_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) 7535{ 7536 bfd_byte *contents; 7537 bfd_byte *p; 7538 bfd_vma len; 7539 7540 contents = bfd_malloc (hdr->sh_size); 7541 if (!contents) 7542 return; 7543 if (!bfd_get_section_contents (abfd, hdr->bfd_section, contents, 0, 7544 hdr->sh_size)) 7545 { 7546 free (contents); 7547 return; 7548 } 7549 p = contents; 7550 if (*(p++) == 'A') 7551 { 7552 len = hdr->sh_size - 1; 7553 while (len > 0) 7554 { 7555 int namelen; 7556 bfd_vma section_len; 7557 7558 section_len = bfd_get_32 (abfd, p); 7559 p += 4; 7560 if (section_len > len) 7561 section_len = len; 7562 len -= section_len; 7563 namelen = strlen ((char *)p) + 1; 7564 section_len -= namelen + 4; 7565 if (strcmp((char *)p, "aeabi") != 0) 7566 { 7567 /* Vendor section. Ignore it. */ 7568 p += namelen + section_len; 7569 } 7570 else 7571 { 7572 p += namelen; 7573 while (section_len > 0) 7574 { 7575 int tag; 7576 unsigned int n; 7577 unsigned int val; 7578 bfd_vma subsection_len; 7579 bfd_byte *end; 7580 7581 tag = read_unsigned_leb128 (abfd, p, &n); 7582 p += n; 7583 subsection_len = bfd_get_32 (abfd, p); 7584 p += 4; 7585 if (subsection_len > section_len) 7586 subsection_len = section_len; 7587 section_len -= subsection_len; 7588 subsection_len -= n + 4; 7589 end = p + subsection_len; 7590 switch (tag) 7591 { 7592 case Tag_File: 7593 while (p < end) 7594 { 7595 bfd_boolean is_string; 7596 7597 tag = read_unsigned_leb128 (abfd, p, &n); 7598 p += n; 7599 if (tag == 4 || tag == 5) 7600 is_string = 1; 7601 else if (tag < 32) 7602 is_string = 0; 7603 else 7604 is_string = (tag & 1) != 0; 7605 if (tag == Tag_compatibility) 7606 { 7607 val = read_unsigned_leb128 (abfd, p, &n); 7608 p += n; 7609 elf32_arm_add_eabi_attr_compat (abfd, val, 7610 (char *)p); 7611 p += strlen ((char *)p) + 1; 7612 } 7613 else if (is_string) 7614 { 7615 elf32_arm_add_eabi_attr_string (abfd, tag, 7616 (char *)p); 7617 p += strlen ((char *)p) + 1; 7618 } 7619 else 7620 { 7621 val = read_unsigned_leb128 (abfd, p, &n); 7622 p += n; 7623 elf32_arm_add_eabi_attr_int (abfd, tag, val); 7624 } 7625 } 7626 break; 7627 case Tag_Section: 7628 case Tag_Symbol: 7629 /* Don't have anywhere convenient to attach these. 7630 Fall through for now. */ 7631 default: 7632 /* Ignore things we don't kow about. */ 7633 p += subsection_len; 7634 subsection_len = 0; 7635 break; 7636 } 7637 } 7638 } 7639 } 7640 } 7641 free (contents); 7642} 7643 | |
7644/* Handle an ARM specific section when reading an object file. This is 7645 called when bfd_section_from_shdr finds a section with an unknown 7646 type. */ 7647 7648static bfd_boolean 7649elf32_arm_section_from_shdr (bfd *abfd, 7650 Elf_Internal_Shdr * hdr, 7651 const char *name, --- 13 unchanged lines hidden (view full) --- 7665 7666 default: 7667 return FALSE; 7668 } 7669 7670 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) 7671 return FALSE; 7672 | 9417/* Handle an ARM specific section when reading an object file. This is 9418 called when bfd_section_from_shdr finds a section with an unknown 9419 type. */ 9420 9421static bfd_boolean 9422elf32_arm_section_from_shdr (bfd *abfd, 9423 Elf_Internal_Shdr * hdr, 9424 const char *name, --- 13 unchanged lines hidden (view full) --- 9438 9439 default: 9440 return FALSE; 9441 } 9442 9443 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) 9444 return FALSE; 9445 |
7673 if (hdr->sh_type == SHT_ARM_ATTRIBUTES) 7674 elf32_arm_parse_attributes(abfd, hdr); | |
7675 return TRUE; 7676} 7677 7678/* A structure used to record a list of sections, independently 7679 of the next and prev fields in the asection structure. */ 7680typedef struct section_list 7681{ 7682 asection * sec; --- 88 unchanged lines hidden (view full) --- 7771 if (entry->next != NULL) 7772 entry->next->prev = entry->prev; 7773 if (entry == sections_with_arm_elf_section_data) 7774 sections_with_arm_elf_section_data = entry->next; 7775 free (entry); 7776 } 7777} 7778 | 9446 return TRUE; 9447} 9448 9449/* A structure used to record a list of sections, independently 9450 of the next and prev fields in the asection structure. */ 9451typedef struct section_list 9452{ 9453 asection * sec; --- 88 unchanged lines hidden (view full) --- 9542 if (entry->next != NULL) 9543 entry->next->prev = entry->prev; 9544 if (entry == sections_with_arm_elf_section_data) 9545 sections_with_arm_elf_section_data = entry->next; 9546 free (entry); 9547 } 9548} 9549 |
7779/* Called for each symbol. Builds a section map based on mapping symbols. 7780 Does not alter any of the symbols. */ | |
7781 | 9550 |
9551typedef struct 9552{ 9553 void *finfo; 9554 struct bfd_link_info *info; 9555 asection *sec; 9556 int sec_shndx; 9557 bfd_boolean (*func) (void *, const char *, Elf_Internal_Sym *, 9558 asection *, struct elf_link_hash_entry *); 9559} output_arch_syminfo; 9560 9561enum map_symbol_type 9562{ 9563 ARM_MAP_ARM, 9564 ARM_MAP_THUMB, 9565 ARM_MAP_DATA 9566}; 9567 9568 9569/* Output a single PLT mapping symbol. */ 9570 |
|
7782static bfd_boolean | 9571static bfd_boolean |
7783elf32_arm_output_symbol_hook (struct bfd_link_info *info, 7784 const char *name, 7785 Elf_Internal_Sym *elfsym, 7786 asection *input_sec, 7787 struct elf_link_hash_entry *h) | 9572elf32_arm_ouput_plt_map_sym (output_arch_syminfo *osi, 9573 enum map_symbol_type type, 9574 bfd_vma offset) |
7788{ | 9575{ |
7789 int mapcount; 7790 elf32_arm_section_map *map; 7791 elf32_arm_section_map *newmap; 7792 _arm_elf_section_data *arm_data; 7793 struct elf32_arm_link_hash_table *globals; | 9576 static const char *names[3] = {"$a", "$t", "$d"}; 9577 struct elf32_arm_link_hash_table *htab; 9578 Elf_Internal_Sym sym; |
7794 | 9579 |
7795 globals = elf32_arm_hash_table (info); 7796 if (globals->vxworks_p 7797 && !elf_vxworks_link_output_symbol_hook (info, name, elfsym, 7798 input_sec, h)) | 9580 htab = elf32_arm_hash_table (osi->info); 9581 sym.st_value = osi->sec->output_section->vma 9582 + osi->sec->output_offset 9583 + offset; 9584 sym.st_size = 0; 9585 sym.st_other = 0; 9586 sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE); 9587 sym.st_shndx = osi->sec_shndx; 9588 if (!osi->func (osi->finfo, names[type], &sym, osi->sec, NULL)) |
7799 return FALSE; | 9589 return FALSE; |
9590 return TRUE; 9591} |
|
7800 | 9592 |
7801 /* Only do this on final link. */ 7802 if (info->relocatable) 7803 return TRUE; | |
7804 | 9593 |
7805 /* Only build a map if we need to byteswap code. */ 7806 if (!globals->byteswap_code) 7807 return TRUE; | 9594/* Output mapping symbols for PLT entries associated with H. */ |
7808 | 9595 |
7809 /* We only want mapping symbols. */ 7810 if (! bfd_is_arm_mapping_symbol_name (name)) | 9596static bfd_boolean 9597elf32_arm_output_plt_map (struct elf_link_hash_entry *h, void *inf) 9598{ 9599 output_arch_syminfo *osi = (output_arch_syminfo *) inf; 9600 struct elf32_arm_link_hash_table *htab; 9601 struct elf32_arm_link_hash_entry *eh; 9602 bfd_vma addr; 9603 9604 htab = elf32_arm_hash_table (osi->info); 9605 9606 if (h->root.type == bfd_link_hash_indirect) |
7811 return TRUE; 7812 | 9607 return TRUE; 9608 |
7813 /* If this section has not been allocated an _arm_elf_section_data 7814 structure then we cannot record anything. */ 7815 arm_data = get_arm_elf_section_data (input_sec); 7816 if (arm_data == NULL) | 9609 if (h->root.type == bfd_link_hash_warning) 9610 /* When warning symbols are created, they **replace** the "real" 9611 entry in the hash table, thus we never get to see the real 9612 symbol in a hash traversal. So look at it now. */ 9613 h = (struct elf_link_hash_entry *) h->root.u.i.link; 9614 9615 if (h->plt.offset == (bfd_vma) -1) |
7817 return TRUE; 7818 | 9616 return TRUE; 9617 |
7819 mapcount = arm_data->mapcount + 1; 7820 map = arm_data->map; | 9618 eh = (struct elf32_arm_link_hash_entry *) h; 9619 addr = h->plt.offset; 9620 if (htab->symbian_p) 9621 { 9622 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) 9623 return FALSE; 9624 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 4)) 9625 return FALSE; 9626 } 9627 else if (htab->vxworks_p) 9628 { 9629 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) 9630 return FALSE; 9631 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 8)) 9632 return FALSE; 9633 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr + 12)) 9634 return FALSE; 9635 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 20)) 9636 return FALSE; 9637 } 9638 else 9639 { 9640 bfd_boolean thumb_stub; |
7821 | 9641 |
7822 /* TODO: This may be inefficient, but we probably don't usually have many 7823 mapping symbols per section. */ 7824 newmap = bfd_realloc (map, mapcount * sizeof (* map)); 7825 if (newmap != NULL) | 9642 thumb_stub = eh->plt_thumb_refcount > 0 && !htab->use_blx; 9643 if (thumb_stub) 9644 { 9645 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_THUMB, addr - 4)) 9646 return FALSE; 9647 } 9648#ifdef FOUR_WORD_PLT 9649 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) 9650 return FALSE; 9651 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_DATA, addr + 12)) 9652 return FALSE; 9653#else 9654 /* A three-word PLT with no Thumb thunk contains only Arm code, 9655 so only need to output a mapping symbol for the first PLT entry and 9656 entries with thumb thunks. */ 9657 if (thumb_stub || addr == 20) 9658 { 9659 if (!elf32_arm_ouput_plt_map_sym (osi, ARM_MAP_ARM, addr)) 9660 return FALSE; 9661 } 9662#endif 9663 } 9664 9665 return TRUE; 9666} 9667 9668 9669/* Output mapping symbols for linker generated sections. */ 9670 9671static bfd_boolean 9672elf32_arm_output_arch_local_syms (bfd *output_bfd, 9673 struct bfd_link_info *info, 9674 void *finfo, bfd_boolean (*func) (void *, const char *, 9675 Elf_Internal_Sym *, 9676 asection *, 9677 struct elf_link_hash_entry *)) 9678{ 9679 output_arch_syminfo osi; 9680 struct elf32_arm_link_hash_table *htab; 9681 bfd_vma offset; 9682 bfd_size_type size; 9683 9684 htab = elf32_arm_hash_table (info); 9685 check_use_blx(htab); 9686 9687 osi.finfo = finfo; 9688 osi.info = info; 9689 osi.func = func; 9690 9691 /* ARM->Thumb glue. */ 9692 if (htab->arm_glue_size > 0) |
7826 { | 9693 { |
7827 arm_data->map = newmap; 7828 arm_data->mapcount = mapcount; | 9694 osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner, 9695 ARM2THUMB_GLUE_SECTION_NAME); |
7829 | 9696 |
7830 newmap[mapcount - 1].vma = elfsym->st_value; 7831 newmap[mapcount - 1].type = name[1]; | 9697 osi.sec_shndx = _bfd_elf_section_from_bfd_section 9698 (output_bfd, osi.sec->output_section); 9699 if (info->shared || htab->root.is_relocatable_executable 9700 || htab->pic_veneer) 9701 size = ARM2THUMB_PIC_GLUE_SIZE; 9702 else if (htab->use_blx) 9703 size = ARM2THUMB_V5_STATIC_GLUE_SIZE; 9704 else 9705 size = ARM2THUMB_STATIC_GLUE_SIZE; 9706 9707 for (offset = 0; offset < htab->arm_glue_size; offset += size) 9708 { 9709 elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, offset); 9710 elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, offset + size - 4); 9711 } |
7832 } 7833 | 9712 } 9713 |
9714 /* Thumb->ARM glue. */ 9715 if (htab->thumb_glue_size > 0) 9716 { 9717 osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner, 9718 THUMB2ARM_GLUE_SECTION_NAME); 9719 9720 osi.sec_shndx = _bfd_elf_section_from_bfd_section 9721 (output_bfd, osi.sec->output_section); 9722 size = THUMB2ARM_GLUE_SIZE; 9723 9724 for (offset = 0; offset < htab->thumb_glue_size; offset += size) 9725 { 9726 elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_THUMB, offset); 9727 elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, offset + 4); 9728 } 9729 } 9730 9731 /* Finally, output mapping symbols for the PLT. */ 9732 if (!htab->splt || htab->splt->size == 0) 9733 return TRUE; 9734 9735 osi.sec_shndx = _bfd_elf_section_from_bfd_section (output_bfd, 9736 htab->splt->output_section); 9737 osi.sec = htab->splt; 9738 /* Output mapping symbols for the plt header. SymbianOS does not have a 9739 plt header. */ 9740 if (htab->vxworks_p) 9741 { 9742 /* VxWorks shared libraries have no PLT header. */ 9743 if (!info->shared) 9744 { 9745 if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0)) 9746 return FALSE; 9747 if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 12)) 9748 return FALSE; 9749 } 9750 } 9751 else if (!htab->symbian_p) 9752 { 9753 if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_ARM, 0)) 9754 return FALSE; 9755#ifndef FOUR_WORD_PLT 9756 if (!elf32_arm_ouput_plt_map_sym (&osi, ARM_MAP_DATA, 16)) 9757 return FALSE; 9758#endif 9759 } 9760 9761 elf_link_hash_traverse (&htab->root, elf32_arm_output_plt_map, (void *) &osi); |
|
7834 return TRUE; 7835} 7836 7837/* Allocate target specific section data. */ 7838 7839static bfd_boolean 7840elf32_arm_new_section_hook (bfd *abfd, asection *sec) 7841{ | 9762 return TRUE; 9763} 9764 9765/* Allocate target specific section data. */ 9766 9767static bfd_boolean 9768elf32_arm_new_section_hook (bfd *abfd, asection *sec) 9769{ |
7842 _arm_elf_section_data *sdata; 7843 bfd_size_type amt = sizeof (*sdata); | 9770 if (!sec->used_by_bfd) 9771 { 9772 _arm_elf_section_data *sdata; 9773 bfd_size_type amt = sizeof (*sdata); |
7844 | 9774 |
7845 sdata = bfd_zalloc (abfd, amt); 7846 if (sdata == NULL) 7847 return FALSE; 7848 sec->used_by_bfd = sdata; | 9775 sdata = bfd_zalloc (abfd, amt); 9776 if (sdata == NULL) 9777 return FALSE; 9778 sec->used_by_bfd = sdata; 9779 } |
7849 7850 record_section_with_arm_elf_section_data (sec); 7851 7852 return _bfd_elf_new_section_hook (abfd, sec); 7853} 7854 7855 7856/* Used to order a list of mapping symbols by address. */ --- 5 unchanged lines hidden (view full) --- 7862 > ((const elf32_arm_section_map *) b)->vma; 7863} 7864 7865 7866/* Do code byteswapping. Return FALSE afterwards so that the section is 7867 written out as normal. */ 7868 7869static bfd_boolean | 9780 9781 record_section_with_arm_elf_section_data (sec); 9782 9783 return _bfd_elf_new_section_hook (abfd, sec); 9784} 9785 9786 9787/* Used to order a list of mapping symbols by address. */ --- 5 unchanged lines hidden (view full) --- 9793 > ((const elf32_arm_section_map *) b)->vma; 9794} 9795 9796 9797/* Do code byteswapping. Return FALSE afterwards so that the section is 9798 written out as normal. */ 9799 9800static bfd_boolean |
7870elf32_arm_write_section (bfd *output_bfd ATTRIBUTE_UNUSED, asection *sec, | 9801elf32_arm_write_section (bfd *output_bfd, 9802 struct bfd_link_info *link_info, asection *sec, |
7871 bfd_byte *contents) 7872{ | 9803 bfd_byte *contents) 9804{ |
7873 int mapcount; | 9805 int mapcount, errcount; |
7874 _arm_elf_section_data *arm_data; | 9806 _arm_elf_section_data *arm_data; |
9807 struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info); |
|
7875 elf32_arm_section_map *map; | 9808 elf32_arm_section_map *map; |
9809 elf32_vfp11_erratum_list *errnode; |
|
7876 bfd_vma ptr; 7877 bfd_vma end; | 9810 bfd_vma ptr; 9811 bfd_vma end; |
7878 bfd_vma offset; | 9812 bfd_vma offset = sec->output_section->vma + sec->output_offset; |
7879 bfd_byte tmp; 7880 int i; 7881 7882 /* If this section has not been allocated an _arm_elf_section_data 7883 structure then we cannot record anything. */ 7884 arm_data = get_arm_elf_section_data (sec); 7885 if (arm_data == NULL) 7886 return FALSE; 7887 7888 mapcount = arm_data->mapcount; 7889 map = arm_data->map; | 9813 bfd_byte tmp; 9814 int i; 9815 9816 /* If this section has not been allocated an _arm_elf_section_data 9817 structure then we cannot record anything. */ 9818 arm_data = get_arm_elf_section_data (sec); 9819 if (arm_data == NULL) 9820 return FALSE; 9821 9822 mapcount = arm_data->mapcount; 9823 map = arm_data->map; |
9824 errcount = arm_data->erratumcount; |
|
7890 | 9825 |
9826 if (errcount != 0) 9827 { 9828 unsigned int endianflip = bfd_big_endian (output_bfd) ? 3 : 0; 9829 9830 for (errnode = arm_data->erratumlist; errnode != 0; 9831 errnode = errnode->next) 9832 { 9833 bfd_vma index = errnode->vma - offset; 9834 9835 switch (errnode->type) 9836 { 9837 case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER: 9838 { 9839 bfd_vma branch_to_veneer; 9840 /* Original condition code of instruction, plus bit mask for 9841 ARM B instruction. */ 9842 unsigned int insn = (errnode->u.b.vfp_insn & 0xf0000000) 9843 | 0x0a000000; 9844 9845 /* The instruction is before the label. */ 9846 index -= 4; 9847 9848 /* Above offset included in -4 below. */ 9849 branch_to_veneer = errnode->u.b.veneer->vma 9850 - errnode->vma - 4; 9851 9852 if ((signed) branch_to_veneer < -(1 << 25) 9853 || (signed) branch_to_veneer >= (1 << 25)) 9854 (*_bfd_error_handler) (_("%B: error: VFP11 veneer out of " 9855 "range"), output_bfd); 9856 9857 insn |= (branch_to_veneer >> 2) & 0xffffff; 9858 contents[endianflip ^ index] = insn & 0xff; 9859 contents[endianflip ^ (index + 1)] = (insn >> 8) & 0xff; 9860 contents[endianflip ^ (index + 2)] = (insn >> 16) & 0xff; 9861 contents[endianflip ^ (index + 3)] = (insn >> 24) & 0xff; 9862 } 9863 break; 9864 9865 case VFP11_ERRATUM_ARM_VENEER: 9866 { 9867 bfd_vma branch_from_veneer; 9868 unsigned int insn; 9869 9870 /* Take size of veneer into account. */ 9871 branch_from_veneer = errnode->u.v.branch->vma 9872 - errnode->vma - 12; 9873 9874 if ((signed) branch_from_veneer < -(1 << 25) 9875 || (signed) branch_from_veneer >= (1 << 25)) 9876 (*_bfd_error_handler) (_("%B: error: VFP11 veneer out of " 9877 "range"), output_bfd); 9878 9879 /* Original instruction. */ 9880 insn = errnode->u.v.branch->u.b.vfp_insn; 9881 contents[endianflip ^ index] = insn & 0xff; 9882 contents[endianflip ^ (index + 1)] = (insn >> 8) & 0xff; 9883 contents[endianflip ^ (index + 2)] = (insn >> 16) & 0xff; 9884 contents[endianflip ^ (index + 3)] = (insn >> 24) & 0xff; 9885 9886 /* Branch back to insn after original insn. */ 9887 insn = 0xea000000 | ((branch_from_veneer >> 2) & 0xffffff); 9888 contents[endianflip ^ (index + 4)] = insn & 0xff; 9889 contents[endianflip ^ (index + 5)] = (insn >> 8) & 0xff; 9890 contents[endianflip ^ (index + 6)] = (insn >> 16) & 0xff; 9891 contents[endianflip ^ (index + 7)] = (insn >> 24) & 0xff; 9892 } 9893 break; 9894 9895 default: 9896 abort (); 9897 } 9898 } 9899 } 9900 |
|
7891 if (mapcount == 0) 7892 return FALSE; 7893 | 9901 if (mapcount == 0) 9902 return FALSE; 9903 |
7894 qsort (map, mapcount, sizeof (* map), elf32_arm_compare_mapping); 7895 7896 offset = sec->output_section->vma + sec->output_offset; 7897 ptr = map[0].vma - offset; 7898 for (i = 0; i < mapcount; i++) | 9904 if (globals->byteswap_code) |
7899 { | 9905 { |
7900 if (i == mapcount - 1) 7901 end = sec->size; 7902 else 7903 end = map[i + 1].vma - offset; | 9906 qsort (map, mapcount, sizeof (* map), elf32_arm_compare_mapping); |
7904 | 9907 |
7905 switch (map[i].type) 7906 { 7907 case 'a': 7908 /* Byte swap code words. */ 7909 while (ptr + 3 < end) 7910 { 7911 tmp = contents[ptr]; 7912 contents[ptr] = contents[ptr + 3]; 7913 contents[ptr + 3] = tmp; 7914 tmp = contents[ptr + 1]; 7915 contents[ptr + 1] = contents[ptr + 2]; 7916 contents[ptr + 2] = tmp; 7917 ptr += 4; 7918 } 7919 break; | 9908 ptr = map[0].vma; 9909 for (i = 0; i < mapcount; i++) 9910 { 9911 if (i == mapcount - 1) 9912 end = sec->size; 9913 else 9914 end = map[i + 1].vma; |
7920 | 9915 |
7921 case 't': 7922 /* Byte swap code halfwords. */ 7923 while (ptr + 1 < end) | 9916 switch (map[i].type) |
7924 { | 9917 { |
7925 tmp = contents[ptr]; 7926 contents[ptr] = contents[ptr + 1]; 7927 contents[ptr + 1] = tmp; 7928 ptr += 2; 7929 } 7930 break; | 9918 case 'a': 9919 /* Byte swap code words. */ 9920 while (ptr + 3 < end) 9921 { 9922 tmp = contents[ptr]; 9923 contents[ptr] = contents[ptr + 3]; 9924 contents[ptr + 3] = tmp; 9925 tmp = contents[ptr + 1]; 9926 contents[ptr + 1] = contents[ptr + 2]; 9927 contents[ptr + 2] = tmp; 9928 ptr += 4; 9929 } 9930 break; |
7931 | 9931 |
7932 case 'd': 7933 /* Leave data alone. */ 7934 break; 7935 } 7936 ptr = end; | 9932 case 't': 9933 /* Byte swap code halfwords. */ 9934 while (ptr + 1 < end) 9935 { 9936 tmp = contents[ptr]; 9937 contents[ptr] = contents[ptr + 1]; 9938 contents[ptr + 1] = tmp; 9939 ptr += 2; 9940 } 9941 break; 9942 9943 case 'd': 9944 /* Leave data alone. */ 9945 break; 9946 } 9947 ptr = end; 9948 } |
7937 } 7938 7939 free (map); 7940 arm_data->mapcount = 0; | 9949 } 9950 9951 free (map); 9952 arm_data->mapcount = 0; |
9953 arm_data->mapsize = 0; |
|
7941 arm_data->map = NULL; 7942 unrecord_section_with_arm_elf_section_data (sec); 7943 7944 return FALSE; 7945} 7946 7947static void 7948unrecord_section_via_map_over_sections (bfd * abfd ATTRIBUTE_UNUSED, 7949 asection * sec, 7950 void * ignore ATTRIBUTE_UNUSED) 7951{ 7952 unrecord_section_with_arm_elf_section_data (sec); 7953} 7954 7955static bfd_boolean 7956elf32_arm_close_and_cleanup (bfd * abfd) 7957{ | 9954 arm_data->map = NULL; 9955 unrecord_section_with_arm_elf_section_data (sec); 9956 9957 return FALSE; 9958} 9959 9960static void 9961unrecord_section_via_map_over_sections (bfd * abfd ATTRIBUTE_UNUSED, 9962 asection * sec, 9963 void * ignore ATTRIBUTE_UNUSED) 9964{ 9965 unrecord_section_with_arm_elf_section_data (sec); 9966} 9967 9968static bfd_boolean 9969elf32_arm_close_and_cleanup (bfd * abfd) 9970{ |
7958 bfd_map_over_sections (abfd, unrecord_section_via_map_over_sections, NULL); | 9971 if (abfd->sections) 9972 bfd_map_over_sections (abfd, 9973 unrecord_section_via_map_over_sections, 9974 NULL); |
7959 7960 return _bfd_elf_close_and_cleanup (abfd); 7961} 7962 | 9975 9976 return _bfd_elf_close_and_cleanup (abfd); 9977} 9978 |
9979static bfd_boolean 9980elf32_arm_bfd_free_cached_info (bfd * abfd) 9981{ 9982 if (abfd->sections) 9983 bfd_map_over_sections (abfd, 9984 unrecord_section_via_map_over_sections, 9985 NULL); 9986 9987 return _bfd_free_cached_info (abfd); 9988} 9989 |
|
7963/* Display STT_ARM_TFUNC symbols as functions. */ 7964 7965static void 7966elf32_arm_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, 7967 asymbol *asym) 7968{ 7969 elf_symbol_type *elfsym = (elf_symbol_type *) asym; 7970 7971 if (ELF_ST_TYPE (elfsym->internal_elf_sym.st_info) == STT_ARM_TFUNC) 7972 elfsym->symbol.flags |= BSF_FUNCTION; 7973} 7974 7975 7976/* Mangle thumb function symbols as we read them in. */ 7977 | 9990/* Display STT_ARM_TFUNC symbols as functions. */ 9991 9992static void 9993elf32_arm_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, 9994 asymbol *asym) 9995{ 9996 elf_symbol_type *elfsym = (elf_symbol_type *) asym; 9997 9998 if (ELF_ST_TYPE (elfsym->internal_elf_sym.st_info) == STT_ARM_TFUNC) 9999 elfsym->symbol.flags |= BSF_FUNCTION; 10000} 10001 10002 10003/* Mangle thumb function symbols as we read them in. */ 10004 |
7978static void | 10005static bfd_boolean |
7979elf32_arm_swap_symbol_in (bfd * abfd, 7980 const void *psrc, 7981 const void *pshn, 7982 Elf_Internal_Sym *dst) 7983{ | 10006elf32_arm_swap_symbol_in (bfd * abfd, 10007 const void *psrc, 10008 const void *pshn, 10009 Elf_Internal_Sym *dst) 10010{ |
7984 bfd_elf32_swap_symbol_in (abfd, psrc, pshn, dst); | 10011 if (!bfd_elf32_swap_symbol_in (abfd, psrc, pshn, dst)) 10012 return FALSE; |
7985 7986 /* New EABI objects mark thumb function symbols by setting the low bit of 7987 the address. Turn these into STT_ARM_TFUNC. */ 7988 if (ELF_ST_TYPE (dst->st_info) == STT_FUNC 7989 && (dst->st_value & 1)) 7990 { 7991 dst->st_info = ELF_ST_INFO (ELF_ST_BIND (dst->st_info), STT_ARM_TFUNC); 7992 dst->st_value &= ~(bfd_vma) 1; 7993 } | 10013 10014 /* New EABI objects mark thumb function symbols by setting the low bit of 10015 the address. Turn these into STT_ARM_TFUNC. */ 10016 if (ELF_ST_TYPE (dst->st_info) == STT_FUNC 10017 && (dst->st_value & 1)) 10018 { 10019 dst->st_info = ELF_ST_INFO (ELF_ST_BIND (dst->st_info), STT_ARM_TFUNC); 10020 dst->st_value &= ~(bfd_vma) 1; 10021 } |
10022 return TRUE; |
|
7994} 7995 7996 7997/* Mangle thumb function symbols as we write them out. */ 7998 7999static void 8000elf32_arm_swap_symbol_out (bfd *abfd, 8001 const Elf_Internal_Sym *src, --- 5 unchanged lines hidden (view full) --- 8007 /* We convert STT_ARM_TFUNC symbols into STT_FUNC with the low bit 8008 of the address set, as per the new EABI. We do this unconditionally 8009 because objcopy does not set the elf header flags until after 8010 it writes out the symbol table. */ 8011 if (ELF_ST_TYPE (src->st_info) == STT_ARM_TFUNC) 8012 { 8013 newsym = *src; 8014 newsym.st_info = ELF_ST_INFO (ELF_ST_BIND (src->st_info), STT_FUNC); | 10023} 10024 10025 10026/* Mangle thumb function symbols as we write them out. */ 10027 10028static void 10029elf32_arm_swap_symbol_out (bfd *abfd, 10030 const Elf_Internal_Sym *src, --- 5 unchanged lines hidden (view full) --- 10036 /* We convert STT_ARM_TFUNC symbols into STT_FUNC with the low bit 10037 of the address set, as per the new EABI. We do this unconditionally 10038 because objcopy does not set the elf header flags until after 10039 it writes out the symbol table. */ 10040 if (ELF_ST_TYPE (src->st_info) == STT_ARM_TFUNC) 10041 { 10042 newsym = *src; 10043 newsym.st_info = ELF_ST_INFO (ELF_ST_BIND (src->st_info), STT_FUNC); |
8015 newsym.st_value |= 1; | 10044 if (newsym.st_shndx != SHN_UNDEF) 10045 { 10046 /* Do this only for defined symbols. At link type, the static 10047 linker will simulate the work of dynamic linker of resolving 10048 symbols and will carry over the thumbness of found symbols to 10049 the output symbol table. It's not clear how it happens, but 10050 the thumbness of undefined symbols can well be different at 10051 runtime, and writing '1' for them will be confusing for users 10052 and possibly for dynamic linker itself. 10053 */ 10054 newsym.st_value |= 1; 10055 } |
8016 8017 src = &newsym; 8018 } 8019 bfd_elf32_swap_symbol_out (abfd, src, cdst, shndx); 8020} 8021 8022/* Add the PT_ARM_EXIDX program header. */ 8023 --- 28 unchanged lines hidden (view full) --- 8052 } 8053 8054 return TRUE; 8055} 8056 8057/* We may add a PT_ARM_EXIDX program header. */ 8058 8059static int | 10056 10057 src = &newsym; 10058 } 10059 bfd_elf32_swap_symbol_out (abfd, src, cdst, shndx); 10060} 10061 10062/* Add the PT_ARM_EXIDX program header. */ 10063 --- 28 unchanged lines hidden (view full) --- 10092 } 10093 10094 return TRUE; 10095} 10096 10097/* We may add a PT_ARM_EXIDX program header. */ 10098 10099static int |
8060elf32_arm_additional_program_headers (bfd *abfd) | 10100elf32_arm_additional_program_headers (bfd *abfd, 10101 struct bfd_link_info *info ATTRIBUTE_UNUSED) |
8061{ 8062 asection *sec; 8063 8064 sec = bfd_get_section_by_name (abfd, ".ARM.exidx"); 8065 if (sec != NULL && (sec->flags & SEC_LOAD) != 0) 8066 return 1; 8067 else 8068 return 0; 8069} 8070 | 10102{ 10103 asection *sec; 10104 10105 sec = bfd_get_section_by_name (abfd, ".ARM.exidx"); 10106 if (sec != NULL && (sec->flags & SEC_LOAD) != 0) 10107 return 1; 10108 else 10109 return 0; 10110} 10111 |
10112/* We have two function types: STT_FUNC and STT_ARM_TFUNC. */ 10113static bfd_boolean 10114elf32_arm_is_function_type (unsigned int type) 10115{ 10116 return (type == STT_FUNC) || (type == STT_ARM_TFUNC); 10117} 10118 |
|
8071/* We use this to override swap_symbol_in and swap_symbol_out. */ 8072const struct elf_size_info elf32_arm_size_info = { 8073 sizeof (Elf32_External_Ehdr), 8074 sizeof (Elf32_External_Phdr), 8075 sizeof (Elf32_External_Shdr), 8076 sizeof (Elf32_External_Rel), 8077 sizeof (Elf32_External_Rela), 8078 sizeof (Elf32_External_Sym), --- 21 unchanged lines hidden (view full) --- 8100#define ELF_ARCH bfd_arch_arm 8101#define ELF_MACHINE_CODE EM_ARM 8102#ifdef __QNXTARGET__ 8103#define ELF_MAXPAGESIZE 0x1000 8104#else 8105#define ELF_MAXPAGESIZE 0x8000 8106#endif 8107#define ELF_MINPAGESIZE 0x1000 | 10119/* We use this to override swap_symbol_in and swap_symbol_out. */ 10120const struct elf_size_info elf32_arm_size_info = { 10121 sizeof (Elf32_External_Ehdr), 10122 sizeof (Elf32_External_Phdr), 10123 sizeof (Elf32_External_Shdr), 10124 sizeof (Elf32_External_Rel), 10125 sizeof (Elf32_External_Rela), 10126 sizeof (Elf32_External_Sym), --- 21 unchanged lines hidden (view full) --- 10148#define ELF_ARCH bfd_arch_arm 10149#define ELF_MACHINE_CODE EM_ARM 10150#ifdef __QNXTARGET__ 10151#define ELF_MAXPAGESIZE 0x1000 10152#else 10153#define ELF_MAXPAGESIZE 0x8000 10154#endif 10155#define ELF_MINPAGESIZE 0x1000 |
10156#define ELF_COMMONPAGESIZE 0x1000 |
|
8108 8109#define bfd_elf32_mkobject elf32_arm_mkobject 8110 8111#define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data 8112#define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data 8113#define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags 8114#define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data 8115#define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create 8116#define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup | 10157 10158#define bfd_elf32_mkobject elf32_arm_mkobject 10159 10160#define bfd_elf32_bfd_copy_private_bfd_data elf32_arm_copy_private_bfd_data 10161#define bfd_elf32_bfd_merge_private_bfd_data elf32_arm_merge_private_bfd_data 10162#define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags 10163#define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data 10164#define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create 10165#define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup |
10166#define bfd_elf32_bfd_reloc_name_lookup elf32_arm_reloc_name_lookup |
|
8117#define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line 8118#define bfd_elf32_find_inliner_info elf32_arm_find_inliner_info 8119#define bfd_elf32_new_section_hook elf32_arm_new_section_hook 8120#define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol 8121#define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup | 10167#define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line 10168#define bfd_elf32_find_inliner_info elf32_arm_find_inliner_info 10169#define bfd_elf32_new_section_hook elf32_arm_new_section_hook 10170#define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol 10171#define bfd_elf32_close_and_cleanup elf32_arm_close_and_cleanup |
8122#define bfd_elf32_bfd_final_link elf32_arm_bfd_final_link | 10172#define bfd_elf32_bfd_free_cached_info elf32_arm_bfd_free_cached_info |
8123 8124#define elf_backend_get_symbol_type elf32_arm_get_symbol_type 8125#define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook | 10173 10174#define elf_backend_get_symbol_type elf32_arm_get_symbol_type 10175#define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook |
10176#define elf_backend_gc_mark_extra_sections elf32_arm_gc_mark_extra_sections |
|
8126#define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook 8127#define elf_backend_check_relocs elf32_arm_check_relocs 8128#define elf_backend_relocate_section elf32_arm_relocate_section 8129#define elf_backend_write_section elf32_arm_write_section 8130#define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol 8131#define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections 8132#define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol 8133#define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections | 10177#define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook 10178#define elf_backend_check_relocs elf32_arm_check_relocs 10179#define elf_backend_relocate_section elf32_arm_relocate_section 10180#define elf_backend_write_section elf32_arm_write_section 10181#define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol 10182#define elf_backend_create_dynamic_sections elf32_arm_create_dynamic_sections 10183#define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol 10184#define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections |
8134#define elf_backend_link_output_symbol_hook elf32_arm_output_symbol_hook | |
8135#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections | 10185#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections |
10186#define elf_backend_init_index_section _bfd_elf_init_2_index_sections |
|
8136#define elf_backend_post_process_headers elf32_arm_post_process_headers 8137#define elf_backend_reloc_type_class elf32_arm_reloc_type_class 8138#define elf_backend_object_p elf32_arm_object_p 8139#define elf_backend_section_flags elf32_arm_section_flags 8140#define elf_backend_fake_sections elf32_arm_fake_sections 8141#define elf_backend_section_from_shdr elf32_arm_section_from_shdr 8142#define elf_backend_final_write_processing elf32_arm_final_write_processing 8143#define elf_backend_copy_indirect_symbol elf32_arm_copy_indirect_symbol 8144#define elf_backend_symbol_processing elf32_arm_symbol_processing 8145#define elf_backend_size_info elf32_arm_size_info 8146#define elf_backend_modify_segment_map elf32_arm_modify_segment_map 8147#define elf_backend_additional_program_headers \ 8148 elf32_arm_additional_program_headers | 10187#define elf_backend_post_process_headers elf32_arm_post_process_headers 10188#define elf_backend_reloc_type_class elf32_arm_reloc_type_class 10189#define elf_backend_object_p elf32_arm_object_p 10190#define elf_backend_section_flags elf32_arm_section_flags 10191#define elf_backend_fake_sections elf32_arm_fake_sections 10192#define elf_backend_section_from_shdr elf32_arm_section_from_shdr 10193#define elf_backend_final_write_processing elf32_arm_final_write_processing 10194#define elf_backend_copy_indirect_symbol elf32_arm_copy_indirect_symbol 10195#define elf_backend_symbol_processing elf32_arm_symbol_processing 10196#define elf_backend_size_info elf32_arm_size_info 10197#define elf_backend_modify_segment_map elf32_arm_modify_segment_map 10198#define elf_backend_additional_program_headers \ 10199 elf32_arm_additional_program_headers |
10200#define elf_backend_output_arch_local_syms \ 10201 elf32_arm_output_arch_local_syms 10202#define elf_backend_begin_write_processing \ 10203 elf32_arm_begin_write_processing 10204#define elf_backend_is_function_type elf32_arm_is_function_type |
|
8149 8150#define elf_backend_can_refcount 1 8151#define elf_backend_can_gc_sections 1 8152#define elf_backend_plt_readonly 1 8153#define elf_backend_want_got_plt 1 8154#define elf_backend_want_plt_sym 0 8155#define elf_backend_may_use_rel_p 1 8156#define elf_backend_may_use_rela_p 0 8157#define elf_backend_default_use_rela_p 0 | 10205 10206#define elf_backend_can_refcount 1 10207#define elf_backend_can_gc_sections 1 10208#define elf_backend_plt_readonly 1 10209#define elf_backend_want_got_plt 1 10210#define elf_backend_want_plt_sym 0 10211#define elf_backend_may_use_rel_p 1 10212#define elf_backend_may_use_rela_p 0 10213#define elf_backend_default_use_rela_p 0 |
8158#define elf_backend_rela_normal 0 | |
8159 8160#define elf_backend_got_header_size 12 8161 | 10214 10215#define elf_backend_got_header_size 12 10216 |
10217#undef elf_backend_obj_attrs_vendor 10218#define elf_backend_obj_attrs_vendor "aeabi" 10219#undef elf_backend_obj_attrs_section 10220#define elf_backend_obj_attrs_section ".ARM.attributes" 10221#undef elf_backend_obj_attrs_arg_type 10222#define elf_backend_obj_attrs_arg_type elf32_arm_obj_attrs_arg_type 10223#undef elf_backend_obj_attrs_section_type 10224#define elf_backend_obj_attrs_section_type SHT_ARM_ATTRIBUTES 10225 |
|
8162#include "elf32-target.h" 8163 8164/* VxWorks Targets */ 8165 8166#undef TARGET_LITTLE_SYM 8167#define TARGET_LITTLE_SYM bfd_elf32_littlearm_vxworks_vec 8168#undef TARGET_LITTLE_NAME 8169#define TARGET_LITTLE_NAME "elf32-littlearm-vxworks" --- 44 unchanged lines hidden (view full) --- 8214 elf_vxworks_emit_relocs 8215 8216#undef elf_backend_may_use_rel_p 8217#define elf_backend_may_use_rel_p 0 8218#undef elf_backend_may_use_rela_p 8219#define elf_backend_may_use_rela_p 1 8220#undef elf_backend_default_use_rela_p 8221#define elf_backend_default_use_rela_p 1 | 10226#include "elf32-target.h" 10227 10228/* VxWorks Targets */ 10229 10230#undef TARGET_LITTLE_SYM 10231#define TARGET_LITTLE_SYM bfd_elf32_littlearm_vxworks_vec 10232#undef TARGET_LITTLE_NAME 10233#define TARGET_LITTLE_NAME "elf32-littlearm-vxworks" --- 44 unchanged lines hidden (view full) --- 10278 elf_vxworks_emit_relocs 10279 10280#undef elf_backend_may_use_rel_p 10281#define elf_backend_may_use_rel_p 0 10282#undef elf_backend_may_use_rela_p 10283#define elf_backend_may_use_rela_p 1 10284#undef elf_backend_default_use_rela_p 10285#define elf_backend_default_use_rela_p 1 |
8222#undef elf_backend_rela_normal 8223#define elf_backend_rela_normal 1 | |
8224#undef elf_backend_want_plt_sym 8225#define elf_backend_want_plt_sym 1 8226#undef ELF_MAXPAGESIZE 8227#define ELF_MAXPAGESIZE 0x1000 8228 8229#include "elf32-target.h" 8230 8231 --- 34 unchanged lines hidden (view full) --- 8266 8267static const struct bfd_elf_special_section 8268elf32_arm_symbian_special_sections[] = 8269{ 8270 /* In a BPABI executable, the dynamic linking sections do not go in 8271 the loadable read-only segment. The post-linker may wish to 8272 refer to these sections, but they are not part of the final 8273 program image. */ | 10286#undef elf_backend_want_plt_sym 10287#define elf_backend_want_plt_sym 1 10288#undef ELF_MAXPAGESIZE 10289#define ELF_MAXPAGESIZE 0x1000 10290 10291#include "elf32-target.h" 10292 10293 --- 34 unchanged lines hidden (view full) --- 10328 10329static const struct bfd_elf_special_section 10330elf32_arm_symbian_special_sections[] = 10331{ 10332 /* In a BPABI executable, the dynamic linking sections do not go in 10333 the loadable read-only segment. The post-linker may wish to 10334 refer to these sections, but they are not part of the final 10335 program image. */ |
8274 { ".dynamic", 8, 0, SHT_DYNAMIC, 0 }, 8275 { ".dynstr", 7, 0, SHT_STRTAB, 0 }, 8276 { ".dynsym", 7, 0, SHT_DYNSYM, 0 }, 8277 { ".got", 4, 0, SHT_PROGBITS, 0 }, 8278 { ".hash", 5, 0, SHT_HASH, 0 }, | 10336 { STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC, 0 }, 10337 { STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB, 0 }, 10338 { STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM, 0 }, 10339 { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, 0 }, 10340 { STRING_COMMA_LEN (".hash"), 0, SHT_HASH, 0 }, |
8279 /* These sections do not need to be writable as the SymbianOS 8280 postlinker will arrange things so that no dynamic relocation is 8281 required. */ | 10341 /* These sections do not need to be writable as the SymbianOS 10342 postlinker will arrange things so that no dynamic relocation is 10343 required. */ |
8282 { ".init_array", 11, 0, SHT_INIT_ARRAY, SHF_ALLOC }, 8283 { ".fini_array", 11, 0, SHT_FINI_ARRAY, SHF_ALLOC }, 8284 { ".preinit_array", 14, 0, SHT_PREINIT_ARRAY, SHF_ALLOC }, 8285 { NULL, 0, 0, 0, 0 } | 10344 { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC }, 10345 { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC }, 10346 { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC }, 10347 { NULL, 0, 0, 0, 0 } |
8286}; 8287 8288static void 8289elf32_arm_symbian_begin_write_processing (bfd *abfd, | 10348}; 10349 10350static void 10351elf32_arm_symbian_begin_write_processing (bfd *abfd, |
8290 struct bfd_link_info *link_info 8291 ATTRIBUTE_UNUSED) | 10352 struct bfd_link_info *link_info) |
8292{ 8293 /* BPABI objects are never loaded directly by an OS kernel; they are 8294 processed by a postlinker first, into an OS-specific format. If 8295 the D_PAGED bit is set on the file, BFD will align segments on 8296 page boundaries, so that an OS can directly map the file. With 8297 BPABI objects, that just results in wasted space. In addition, 8298 because we clear the D_PAGED bit, map_sections_to_segments will 8299 recognize that the program headers should not be mapped into any 8300 loadable segment. */ 8301 abfd->flags &= ~D_PAGED; | 10353{ 10354 /* BPABI objects are never loaded directly by an OS kernel; they are 10355 processed by a postlinker first, into an OS-specific format. If 10356 the D_PAGED bit is set on the file, BFD will align segments on 10357 page boundaries, so that an OS can directly map the file. With 10358 BPABI objects, that just results in wasted space. In addition, 10359 because we clear the D_PAGED bit, map_sections_to_segments will 10360 recognize that the program headers should not be mapped into any 10361 loadable segment. */ 10362 abfd->flags &= ~D_PAGED; |
10363 elf32_arm_begin_write_processing(abfd, link_info); |
|
8302} 8303 8304static bfd_boolean 8305elf32_arm_symbian_modify_segment_map (bfd *abfd, 8306 struct bfd_link_info *info) 8307{ 8308 struct elf_segment_map *m; 8309 asection *dynsec; 8310 8311 /* BPABI shared libraries and executables should have a PT_DYNAMIC 8312 segment. However, because the .dynamic section is not marked 8313 with SEC_LOAD, the generic ELF code will not create such a 8314 segment. */ 8315 dynsec = bfd_get_section_by_name (abfd, ".dynamic"); 8316 if (dynsec) 8317 { | 10364} 10365 10366static bfd_boolean 10367elf32_arm_symbian_modify_segment_map (bfd *abfd, 10368 struct bfd_link_info *info) 10369{ 10370 struct elf_segment_map *m; 10371 asection *dynsec; 10372 10373 /* BPABI shared libraries and executables should have a PT_DYNAMIC 10374 segment. However, because the .dynamic section is not marked 10375 with SEC_LOAD, the generic ELF code will not create such a 10376 segment. */ 10377 dynsec = bfd_get_section_by_name (abfd, ".dynamic"); 10378 if (dynsec) 10379 { |
8318 m = _bfd_elf_make_dynamic_segment (abfd, dynsec); 8319 m->next = elf_tdata (abfd)->segment_map; 8320 elf_tdata (abfd)->segment_map = m; | 10380 for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) 10381 if (m->p_type == PT_DYNAMIC) 10382 break; 10383 10384 if (m == NULL) 10385 { 10386 m = _bfd_elf_make_dynamic_segment (abfd, dynsec); 10387 m->next = elf_tdata (abfd)->segment_map; 10388 elf_tdata (abfd)->segment_map = m; 10389 } |
8321 } 8322 8323 /* Also call the generic arm routine. */ 8324 return elf32_arm_modify_segment_map (abfd, info); 8325} 8326 8327#undef elf32_bed 8328#define elf32_bed elf32_arm_symbian_bed --- 32 unchanged lines hidden (view full) --- 8361#define elf_backend_want_got_plt 0 8362 8363#undef elf_backend_may_use_rel_p 8364#define elf_backend_may_use_rel_p 1 8365#undef elf_backend_may_use_rela_p 8366#define elf_backend_may_use_rela_p 0 8367#undef elf_backend_default_use_rela_p 8368#define elf_backend_default_use_rela_p 0 | 10390 } 10391 10392 /* Also call the generic arm routine. */ 10393 return elf32_arm_modify_segment_map (abfd, info); 10394} 10395 10396#undef elf32_bed 10397#define elf32_bed elf32_arm_symbian_bed --- 32 unchanged lines hidden (view full) --- 10430#define elf_backend_want_got_plt 0 10431 10432#undef elf_backend_may_use_rel_p 10433#define elf_backend_may_use_rel_p 1 10434#undef elf_backend_may_use_rela_p 10435#define elf_backend_may_use_rela_p 0 10436#undef elf_backend_default_use_rela_p 10437#define elf_backend_default_use_rela_p 0 |
8369#undef elf_backend_rela_normal 8370#define elf_backend_rela_normal 0 | |
8371#undef elf_backend_want_plt_sym 8372#define elf_backend_want_plt_sym 0 8373#undef ELF_MAXPAGESIZE 8374#define ELF_MAXPAGESIZE 0x8000 8375 8376#include "elf32-target.h" | 10438#undef elf_backend_want_plt_sym 10439#define elf_backend_want_plt_sym 0 10440#undef ELF_MAXPAGESIZE 10441#define ELF_MAXPAGESIZE 0x8000 10442 10443#include "elf32-target.h" |