1 /* Target-dependent code for GNU/Linux i386. 2 3 Copyright (C) 2000-2019 Free Software Foundation, Inc. 4 5 This file is part of GDB. 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 3 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, see <http://www.gnu.org/licenses/>. */ 19 20 #include "defs.h" 21 #include "gdbcore.h" 22 #include "frame.h" 23 #include "value.h" 24 #include "regcache.h" 25 #include "regset.h" 26 #include "inferior.h" 27 #include "osabi.h" 28 #include "reggroups.h" 29 #include "dwarf2-frame.h" 30 #include "i386-tdep.h" 31 #include "i386-linux-tdep.h" 32 #include "linux-tdep.h" 33 #include "utils.h" 34 #include "glibc-tdep.h" 35 #include "solib-svr4.h" 36 #include "symtab.h" 37 #include "arch-utils.h" 38 #include "xml-syscall.h" 39 40 #include "i387-tdep.h" 41 #include "common/x86-xstate.h" 42 43 /* The syscall's XML filename for i386. */ 44 #define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml" 45 46 #include "record-full.h" 47 #include "linux-record.h" 48 49 #include "arch/i386.h" 50 #include "target-descriptions.h" 51 52 /* Return non-zero, when the register is in the corresponding register 53 group. Put the LINUX_ORIG_EAX register in the system group. */ 54 static int 55 i386_linux_register_reggroup_p (struct gdbarch *gdbarch, int regnum, 56 struct reggroup *group) 57 { 58 if (regnum == I386_LINUX_ORIG_EAX_REGNUM) 59 return (group == system_reggroup 60 || group == save_reggroup 61 || group == restore_reggroup); 62 return i386_register_reggroup_p (gdbarch, regnum, group); 63 } 64 65 66 /* Recognizing signal handler frames. */ 67 68 /* GNU/Linux has two flavors of signals. Normal signal handlers, and 69 "realtime" (RT) signals. The RT signals can provide additional 70 information to the signal handler if the SA_SIGINFO flag is set 71 when establishing a signal handler using `sigaction'. It is not 72 unlikely that future versions of GNU/Linux will support SA_SIGINFO 73 for normal signals too. */ 74 75 /* When the i386 Linux kernel calls a signal handler and the 76 SA_RESTORER flag isn't set, the return address points to a bit of 77 code on the stack. This function returns whether the PC appears to 78 be within this bit of code. 79 80 The instruction sequence for normal signals is 81 pop %eax 82 mov $0x77, %eax 83 int $0x80 84 or 0x58 0xb8 0x77 0x00 0x00 0x00 0xcd 0x80. 85 86 Checking for the code sequence should be somewhat reliable, because 87 the effect is to call the system call sigreturn. This is unlikely 88 to occur anywhere other than in a signal trampoline. 89 90 It kind of sucks that we have to read memory from the process in 91 order to identify a signal trampoline, but there doesn't seem to be 92 any other way. Therefore we only do the memory reads if no 93 function name could be identified, which should be the case since 94 the code is on the stack. 95 96 Detection of signal trampolines for handlers that set the 97 SA_RESTORER flag is in general not possible. Unfortunately this is 98 what the GNU C Library has been doing for quite some time now. 99 However, as of version 2.1.2, the GNU C Library uses signal 100 trampolines (named __restore and __restore_rt) that are identical 101 to the ones used by the kernel. Therefore, these trampolines are 102 supported too. */ 103 104 #define LINUX_SIGTRAMP_INSN0 0x58 /* pop %eax */ 105 #define LINUX_SIGTRAMP_OFFSET0 0 106 #define LINUX_SIGTRAMP_INSN1 0xb8 /* mov $NNNN, %eax */ 107 #define LINUX_SIGTRAMP_OFFSET1 1 108 #define LINUX_SIGTRAMP_INSN2 0xcd /* int */ 109 #define LINUX_SIGTRAMP_OFFSET2 6 110 111 static const gdb_byte linux_sigtramp_code[] = 112 { 113 LINUX_SIGTRAMP_INSN0, /* pop %eax */ 114 LINUX_SIGTRAMP_INSN1, 0x77, 0x00, 0x00, 0x00, /* mov $0x77, %eax */ 115 LINUX_SIGTRAMP_INSN2, 0x80 /* int $0x80 */ 116 }; 117 118 #define LINUX_SIGTRAMP_LEN (sizeof linux_sigtramp_code) 119 120 /* If THIS_FRAME is a sigtramp routine, return the address of the 121 start of the routine. Otherwise, return 0. */ 122 123 static CORE_ADDR 124 i386_linux_sigtramp_start (struct frame_info *this_frame) 125 { 126 CORE_ADDR pc = get_frame_pc (this_frame); 127 gdb_byte buf[LINUX_SIGTRAMP_LEN]; 128 129 /* We only recognize a signal trampoline if PC is at the start of 130 one of the three instructions. We optimize for finding the PC at 131 the start, as will be the case when the trampoline is not the 132 first frame on the stack. We assume that in the case where the 133 PC is not at the start of the instruction sequence, there will be 134 a few trailing readable bytes on the stack. */ 135 136 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN)) 137 return 0; 138 139 if (buf[0] != LINUX_SIGTRAMP_INSN0) 140 { 141 int adjust; 142 143 switch (buf[0]) 144 { 145 case LINUX_SIGTRAMP_INSN1: 146 adjust = LINUX_SIGTRAMP_OFFSET1; 147 break; 148 case LINUX_SIGTRAMP_INSN2: 149 adjust = LINUX_SIGTRAMP_OFFSET2; 150 break; 151 default: 152 return 0; 153 } 154 155 pc -= adjust; 156 157 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_SIGTRAMP_LEN)) 158 return 0; 159 } 160 161 if (memcmp (buf, linux_sigtramp_code, LINUX_SIGTRAMP_LEN) != 0) 162 return 0; 163 164 return pc; 165 } 166 167 /* This function does the same for RT signals. Here the instruction 168 sequence is 169 mov $0xad, %eax 170 int $0x80 171 or 0xb8 0xad 0x00 0x00 0x00 0xcd 0x80. 172 173 The effect is to call the system call rt_sigreturn. */ 174 175 #define LINUX_RT_SIGTRAMP_INSN0 0xb8 /* mov $NNNN, %eax */ 176 #define LINUX_RT_SIGTRAMP_OFFSET0 0 177 #define LINUX_RT_SIGTRAMP_INSN1 0xcd /* int */ 178 #define LINUX_RT_SIGTRAMP_OFFSET1 5 179 180 static const gdb_byte linux_rt_sigtramp_code[] = 181 { 182 LINUX_RT_SIGTRAMP_INSN0, 0xad, 0x00, 0x00, 0x00, /* mov $0xad, %eax */ 183 LINUX_RT_SIGTRAMP_INSN1, 0x80 /* int $0x80 */ 184 }; 185 186 #define LINUX_RT_SIGTRAMP_LEN (sizeof linux_rt_sigtramp_code) 187 188 /* If THIS_FRAME is an RT sigtramp routine, return the address of the 189 start of the routine. Otherwise, return 0. */ 190 191 static CORE_ADDR 192 i386_linux_rt_sigtramp_start (struct frame_info *this_frame) 193 { 194 CORE_ADDR pc = get_frame_pc (this_frame); 195 gdb_byte buf[LINUX_RT_SIGTRAMP_LEN]; 196 197 /* We only recognize a signal trampoline if PC is at the start of 198 one of the two instructions. We optimize for finding the PC at 199 the start, as will be the case when the trampoline is not the 200 first frame on the stack. We assume that in the case where the 201 PC is not at the start of the instruction sequence, there will be 202 a few trailing readable bytes on the stack. */ 203 204 if (!safe_frame_unwind_memory (this_frame, pc, buf, LINUX_RT_SIGTRAMP_LEN)) 205 return 0; 206 207 if (buf[0] != LINUX_RT_SIGTRAMP_INSN0) 208 { 209 if (buf[0] != LINUX_RT_SIGTRAMP_INSN1) 210 return 0; 211 212 pc -= LINUX_RT_SIGTRAMP_OFFSET1; 213 214 if (!safe_frame_unwind_memory (this_frame, pc, buf, 215 LINUX_RT_SIGTRAMP_LEN)) 216 return 0; 217 } 218 219 if (memcmp (buf, linux_rt_sigtramp_code, LINUX_RT_SIGTRAMP_LEN) != 0) 220 return 0; 221 222 return pc; 223 } 224 225 /* Return whether THIS_FRAME corresponds to a GNU/Linux sigtramp 226 routine. */ 227 228 static int 229 i386_linux_sigtramp_p (struct frame_info *this_frame) 230 { 231 CORE_ADDR pc = get_frame_pc (this_frame); 232 const char *name; 233 234 find_pc_partial_function (pc, &name, NULL, NULL); 235 236 /* If we have NAME, we can optimize the search. The trampolines are 237 named __restore and __restore_rt. However, they aren't dynamically 238 exported from the shared C library, so the trampoline may appear to 239 be part of the preceding function. This should always be sigaction, 240 __sigaction, or __libc_sigaction (all aliases to the same function). */ 241 if (name == NULL || strstr (name, "sigaction") != NULL) 242 return (i386_linux_sigtramp_start (this_frame) != 0 243 || i386_linux_rt_sigtramp_start (this_frame) != 0); 244 245 return (strcmp ("__restore", name) == 0 246 || strcmp ("__restore_rt", name) == 0); 247 } 248 249 /* Return one if the PC of THIS_FRAME is in a signal trampoline which 250 may have DWARF-2 CFI. */ 251 252 static int 253 i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch, 254 struct frame_info *this_frame) 255 { 256 CORE_ADDR pc = get_frame_pc (this_frame); 257 const char *name; 258 259 find_pc_partial_function (pc, &name, NULL, NULL); 260 261 /* If a vsyscall DSO is in use, the signal trampolines may have these 262 names. */ 263 if (name && (strcmp (name, "__kernel_sigreturn") == 0 264 || strcmp (name, "__kernel_rt_sigreturn") == 0)) 265 return 1; 266 267 return 0; 268 } 269 270 /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */ 271 #define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20 272 273 /* Assuming THIS_FRAME is a GNU/Linux sigtramp routine, return the 274 address of the associated sigcontext structure. */ 275 276 static CORE_ADDR 277 i386_linux_sigcontext_addr (struct frame_info *this_frame) 278 { 279 struct gdbarch *gdbarch = get_frame_arch (this_frame); 280 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 281 CORE_ADDR pc; 282 CORE_ADDR sp; 283 gdb_byte buf[4]; 284 285 get_frame_register (this_frame, I386_ESP_REGNUM, buf); 286 sp = extract_unsigned_integer (buf, 4, byte_order); 287 288 pc = i386_linux_sigtramp_start (this_frame); 289 if (pc) 290 { 291 /* The sigcontext structure lives on the stack, right after 292 the signum argument. We determine the address of the 293 sigcontext structure by looking at the frame's stack 294 pointer. Keep in mind that the first instruction of the 295 sigtramp code is "pop %eax". If the PC is after this 296 instruction, adjust the returned value accordingly. */ 297 if (pc == get_frame_pc (this_frame)) 298 return sp + 4; 299 return sp; 300 } 301 302 pc = i386_linux_rt_sigtramp_start (this_frame); 303 if (pc) 304 { 305 CORE_ADDR ucontext_addr; 306 307 /* The sigcontext structure is part of the user context. A 308 pointer to the user context is passed as the third argument 309 to the signal handler. */ 310 read_memory (sp + 8, buf, 4); 311 ucontext_addr = extract_unsigned_integer (buf, 4, byte_order); 312 return ucontext_addr + I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET; 313 } 314 315 error (_("Couldn't recognize signal trampoline.")); 316 return 0; 317 } 318 319 /* Set the program counter for process PTID to PC. */ 320 321 static void 322 i386_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) 323 { 324 regcache_cooked_write_unsigned (regcache, I386_EIP_REGNUM, pc); 325 326 /* We must be careful with modifying the program counter. If we 327 just interrupted a system call, the kernel might try to restart 328 it when we resume the inferior. On restarting the system call, 329 the kernel will try backing up the program counter even though it 330 no longer points at the system call. This typically results in a 331 SIGSEGV or SIGILL. We can prevent this by writing `-1' in the 332 "orig_eax" pseudo-register. 333 334 Note that "orig_eax" is saved when setting up a dummy call frame. 335 This means that it is properly restored when that frame is 336 popped, and that the interrupted system call will be restarted 337 when we resume the inferior on return from a function call from 338 within GDB. In all other cases the system call will not be 339 restarted. */ 340 regcache_cooked_write_unsigned (regcache, I386_LINUX_ORIG_EAX_REGNUM, -1); 341 } 342 343 /* Record all registers but IP register for process-record. */ 344 345 static int 346 i386_all_but_ip_registers_record (struct regcache *regcache) 347 { 348 if (record_full_arch_list_add_reg (regcache, I386_EAX_REGNUM)) 349 return -1; 350 if (record_full_arch_list_add_reg (regcache, I386_ECX_REGNUM)) 351 return -1; 352 if (record_full_arch_list_add_reg (regcache, I386_EDX_REGNUM)) 353 return -1; 354 if (record_full_arch_list_add_reg (regcache, I386_EBX_REGNUM)) 355 return -1; 356 if (record_full_arch_list_add_reg (regcache, I386_ESP_REGNUM)) 357 return -1; 358 if (record_full_arch_list_add_reg (regcache, I386_EBP_REGNUM)) 359 return -1; 360 if (record_full_arch_list_add_reg (regcache, I386_ESI_REGNUM)) 361 return -1; 362 if (record_full_arch_list_add_reg (regcache, I386_EDI_REGNUM)) 363 return -1; 364 if (record_full_arch_list_add_reg (regcache, I386_EFLAGS_REGNUM)) 365 return -1; 366 367 return 0; 368 } 369 370 /* i386_canonicalize_syscall maps from the native i386 Linux set 371 of syscall ids into a canonical set of syscall ids used by 372 process record (a mostly trivial mapping, since the canonical 373 set was originally taken from the i386 set). */ 374 375 static enum gdb_syscall 376 i386_canonicalize_syscall (int syscall) 377 { 378 enum { i386_syscall_max = 499 }; 379 380 if (syscall <= i386_syscall_max) 381 return (enum gdb_syscall) syscall; 382 else 383 return gdb_sys_no_syscall; 384 } 385 386 /* Value of the sigcode in case of a boundary fault. */ 387 388 #define SIG_CODE_BONDARY_FAULT 3 389 390 /* i386 GNU/Linux implementation of the handle_segmentation_fault 391 gdbarch hook. Displays information related to MPX bound 392 violations. */ 393 void 394 i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch, 395 struct ui_out *uiout) 396 { 397 /* -Wmaybe-uninitialized */ 398 CORE_ADDR lower_bound = 0, upper_bound = 0, access = 0; 399 int is_upper; 400 long sig_code = 0; 401 402 if (!i386_mpx_enabled ()) 403 return; 404 405 TRY 406 { 407 /* Sigcode evaluates if the actual segfault is a boundary violation. */ 408 sig_code = parse_and_eval_long ("$_siginfo.si_code\n"); 409 410 lower_bound 411 = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._lower"); 412 upper_bound 413 = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._upper"); 414 access 415 = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); 416 } 417 CATCH (exception, RETURN_MASK_ALL) 418 { 419 return; 420 } 421 END_CATCH 422 423 /* If this is not a boundary violation just return. */ 424 if (sig_code != SIG_CODE_BONDARY_FAULT) 425 return; 426 427 is_upper = (access > upper_bound ? 1 : 0); 428 429 uiout->text ("\n"); 430 if (is_upper) 431 uiout->field_string ("sigcode-meaning", _("Upper bound violation")); 432 else 433 uiout->field_string ("sigcode-meaning", _("Lower bound violation")); 434 435 uiout->text (_(" while accessing address ")); 436 uiout->field_fmt ("bound-access", "%s", paddress (gdbarch, access)); 437 438 uiout->text (_("\nBounds: [lower = ")); 439 uiout->field_fmt ("lower-bound", "%s", paddress (gdbarch, lower_bound)); 440 441 uiout->text (_(", upper = ")); 442 uiout->field_fmt ("upper-bound", "%s", paddress (gdbarch, upper_bound)); 443 444 uiout->text (_("]")); 445 } 446 447 /* Parse the arguments of current system call instruction and record 448 the values of the registers and memory that will be changed into 449 "record_arch_list". This instruction is "int 0x80" (Linux 450 Kernel2.4) or "sysenter" (Linux Kernel 2.6). 451 452 Return -1 if something wrong. */ 453 454 static struct linux_record_tdep i386_linux_record_tdep; 455 456 static int 457 i386_linux_intx80_sysenter_syscall_record (struct regcache *regcache) 458 { 459 int ret; 460 LONGEST syscall_native; 461 enum gdb_syscall syscall_gdb; 462 463 regcache_raw_read_signed (regcache, I386_EAX_REGNUM, &syscall_native); 464 465 syscall_gdb = i386_canonicalize_syscall (syscall_native); 466 467 if (syscall_gdb < 0) 468 { 469 printf_unfiltered (_("Process record and replay target doesn't " 470 "support syscall number %s\n"), 471 plongest (syscall_native)); 472 return -1; 473 } 474 475 if (syscall_gdb == gdb_sys_sigreturn 476 || syscall_gdb == gdb_sys_rt_sigreturn) 477 { 478 if (i386_all_but_ip_registers_record (regcache)) 479 return -1; 480 return 0; 481 } 482 483 ret = record_linux_system_call (syscall_gdb, regcache, 484 &i386_linux_record_tdep); 485 if (ret) 486 return ret; 487 488 /* Record the return value of the system call. */ 489 if (record_full_arch_list_add_reg (regcache, I386_EAX_REGNUM)) 490 return -1; 491 492 return 0; 493 } 494 495 #define I386_LINUX_xstate 270 496 #define I386_LINUX_frame_size 732 497 498 static int 499 i386_linux_record_signal (struct gdbarch *gdbarch, 500 struct regcache *regcache, 501 enum gdb_signal signal) 502 { 503 ULONGEST esp; 504 505 if (i386_all_but_ip_registers_record (regcache)) 506 return -1; 507 508 if (record_full_arch_list_add_reg (regcache, I386_EIP_REGNUM)) 509 return -1; 510 511 /* Record the change in the stack. */ 512 regcache_raw_read_unsigned (regcache, I386_ESP_REGNUM, &esp); 513 /* This is for xstate. 514 sp -= sizeof (struct _fpstate); */ 515 esp -= I386_LINUX_xstate; 516 /* This is for frame_size. 517 sp -= sizeof (struct rt_sigframe); */ 518 esp -= I386_LINUX_frame_size; 519 if (record_full_arch_list_add_mem (esp, 520 I386_LINUX_xstate + I386_LINUX_frame_size)) 521 return -1; 522 523 if (record_full_arch_list_add_end ()) 524 return -1; 525 526 return 0; 527 } 528 529 530 /* Core of the implementation for gdbarch get_syscall_number. Get pending 531 syscall number from REGCACHE. If there is no pending syscall -1 will be 532 returned. Pending syscall means ptrace has stepped into the syscall but 533 another ptrace call will step out. PC is right after the int $0x80 534 / syscall / sysenter instruction in both cases, PC does not change during 535 the second ptrace step. */ 536 537 static LONGEST 538 i386_linux_get_syscall_number_from_regcache (struct regcache *regcache) 539 { 540 struct gdbarch *gdbarch = regcache->arch (); 541 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 542 /* The content of a register. */ 543 gdb_byte buf[4]; 544 /* The result. */ 545 LONGEST ret; 546 547 /* Getting the system call number from the register. 548 When dealing with x86 architecture, this information 549 is stored at %eax register. */ 550 regcache->cooked_read (I386_LINUX_ORIG_EAX_REGNUM, buf); 551 552 ret = extract_signed_integer (buf, 4, byte_order); 553 554 return ret; 555 } 556 557 /* Wrapper for i386_linux_get_syscall_number_from_regcache to make it 558 compatible with gdbarch get_syscall_number method prototype. */ 559 560 static LONGEST 561 i386_linux_get_syscall_number (struct gdbarch *gdbarch, 562 thread_info *thread) 563 { 564 struct regcache *regcache = get_thread_regcache (thread); 565 566 return i386_linux_get_syscall_number_from_regcache (regcache); 567 } 568 569 /* The register sets used in GNU/Linux ELF core-dumps are identical to 570 the register sets in `struct user' that are used for a.out 571 core-dumps. These are also used by ptrace(2). The corresponding 572 types are `elf_gregset_t' for the general-purpose registers (with 573 `elf_greg_t' the type of a single GP register) and `elf_fpregset_t' 574 for the floating-point registers. 575 576 Those types used to be available under the names `gregset_t' and 577 `fpregset_t' too, and GDB used those names in the past. But those 578 names are now used for the register sets used in the `mcontext_t' 579 type, which have a different size and layout. */ 580 581 /* Mapping between the general-purpose registers in `struct user' 582 format and GDB's register cache layout. */ 583 584 /* From <sys/reg.h>. */ 585 int i386_linux_gregset_reg_offset[] = 586 { 587 6 * 4, /* %eax */ 588 1 * 4, /* %ecx */ 589 2 * 4, /* %edx */ 590 0 * 4, /* %ebx */ 591 15 * 4, /* %esp */ 592 5 * 4, /* %ebp */ 593 3 * 4, /* %esi */ 594 4 * 4, /* %edi */ 595 12 * 4, /* %eip */ 596 14 * 4, /* %eflags */ 597 13 * 4, /* %cs */ 598 16 * 4, /* %ss */ 599 7 * 4, /* %ds */ 600 8 * 4, /* %es */ 601 9 * 4, /* %fs */ 602 10 * 4, /* %gs */ 603 -1, -1, -1, -1, -1, -1, -1, -1, 604 -1, -1, -1, -1, -1, -1, -1, -1, 605 -1, -1, -1, -1, -1, -1, -1, -1, 606 -1, 607 -1, -1, -1, -1, -1, -1, -1, -1, 608 -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */ 609 -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */ 610 -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */ 611 -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */ 612 -1, /* PKRU register */ 613 11 * 4, /* "orig_eax" */ 614 }; 615 616 /* Mapping between the general-purpose registers in `struct 617 sigcontext' format and GDB's register cache layout. */ 618 619 /* From <asm/sigcontext.h>. */ 620 static int i386_linux_sc_reg_offset[] = 621 { 622 11 * 4, /* %eax */ 623 10 * 4, /* %ecx */ 624 9 * 4, /* %edx */ 625 8 * 4, /* %ebx */ 626 7 * 4, /* %esp */ 627 6 * 4, /* %ebp */ 628 5 * 4, /* %esi */ 629 4 * 4, /* %edi */ 630 14 * 4, /* %eip */ 631 16 * 4, /* %eflags */ 632 15 * 4, /* %cs */ 633 18 * 4, /* %ss */ 634 3 * 4, /* %ds */ 635 2 * 4, /* %es */ 636 1 * 4, /* %fs */ 637 0 * 4 /* %gs */ 638 }; 639 640 /* Get XSAVE extended state xcr0 from core dump. */ 641 642 uint64_t 643 i386_linux_core_read_xcr0 (bfd *abfd) 644 { 645 asection *xstate = bfd_get_section_by_name (abfd, ".reg-xstate"); 646 uint64_t xcr0; 647 648 if (xstate) 649 { 650 size_t size = bfd_section_size (abfd, xstate); 651 652 /* Check extended state size. */ 653 if (size < X86_XSTATE_AVX_SIZE) 654 xcr0 = X86_XSTATE_SSE_MASK; 655 else 656 { 657 char contents[8]; 658 659 if (! bfd_get_section_contents (abfd, xstate, contents, 660 I386_LINUX_XSAVE_XCR0_OFFSET, 661 8)) 662 { 663 warning (_("Couldn't read `xcr0' bytes from " 664 "`.reg-xstate' section in core file.")); 665 return 0; 666 } 667 668 xcr0 = bfd_get_64 (abfd, contents); 669 } 670 } 671 else 672 xcr0 = 0; 673 674 return xcr0; 675 } 676 677 /* See i386-linux-tdep.h. */ 678 679 const struct target_desc * 680 i386_linux_read_description (uint64_t xcr0) 681 { 682 if (xcr0 == 0) 683 return NULL; 684 685 static struct target_desc *i386_linux_tdescs \ 686 [2/*X87*/][2/*SSE*/][2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/] = {}; 687 struct target_desc **tdesc; 688 689 tdesc = &i386_linux_tdescs[(xcr0 & X86_XSTATE_X87) ? 1 : 0] 690 [(xcr0 & X86_XSTATE_SSE) ? 1 : 0] 691 [(xcr0 & X86_XSTATE_AVX) ? 1 : 0] 692 [(xcr0 & X86_XSTATE_MPX) ? 1 : 0] 693 [(xcr0 & X86_XSTATE_AVX512) ? 1 : 0] 694 [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]; 695 696 if (*tdesc == NULL) 697 *tdesc = i386_create_target_description (xcr0, true); 698 699 return *tdesc; 700 } 701 702 /* Get Linux/x86 target description from core dump. */ 703 704 static const struct target_desc * 705 i386_linux_core_read_description (struct gdbarch *gdbarch, 706 struct target_ops *target, 707 bfd *abfd) 708 { 709 /* Linux/i386. */ 710 uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd); 711 const struct target_desc *tdesc = i386_linux_read_description (xcr0); 712 713 if (tdesc != NULL) 714 return tdesc; 715 716 if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL) 717 return i386_linux_read_description (X86_XSTATE_SSE_MASK); 718 else 719 return i386_linux_read_description (X86_XSTATE_X87_MASK); 720 } 721 722 /* Similar to i386_supply_fpregset, but use XSAVE extended state. */ 723 724 static void 725 i386_linux_supply_xstateregset (const struct regset *regset, 726 struct regcache *regcache, int regnum, 727 const void *xstateregs, size_t len) 728 { 729 i387_supply_xsave (regcache, regnum, xstateregs); 730 } 731 732 struct type * 733 x86_linux_get_siginfo_type (struct gdbarch *gdbarch) 734 { 735 return linux_get_siginfo_type_with_fields (gdbarch, LINUX_SIGINFO_FIELD_ADDR_BND); 736 } 737 738 /* Similar to i386_collect_fpregset, but use XSAVE extended state. */ 739 740 static void 741 i386_linux_collect_xstateregset (const struct regset *regset, 742 const struct regcache *regcache, 743 int regnum, void *xstateregs, size_t len) 744 { 745 i387_collect_xsave (regcache, regnum, xstateregs, 1); 746 } 747 748 /* Register set definitions. */ 749 750 static const struct regset i386_linux_xstateregset = 751 { 752 NULL, 753 i386_linux_supply_xstateregset, 754 i386_linux_collect_xstateregset 755 }; 756 757 /* Iterate over core file register note sections. */ 758 759 static void 760 i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, 761 iterate_over_regset_sections_cb *cb, 762 void *cb_data, 763 const struct regcache *regcache) 764 { 765 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); 766 767 cb (".reg", 68, 68, &i386_gregset, NULL, cb_data); 768 769 if (tdep->xcr0 & X86_XSTATE_AVX) 770 cb (".reg-xstate", X86_XSTATE_SIZE (tdep->xcr0), 771 X86_XSTATE_SIZE (tdep->xcr0), &i386_linux_xstateregset, 772 "XSAVE extended state", cb_data); 773 else if (tdep->xcr0 & X86_XSTATE_SSE) 774 cb (".reg-xfp", 512, 512, &i386_fpregset, "extended floating-point", 775 cb_data); 776 else 777 cb (".reg2", 108, 108, &i386_fpregset, NULL, cb_data); 778 } 779 780 /* Linux kernel shows PC value after the 'int $0x80' instruction even if 781 inferior is still inside the syscall. On next PTRACE_SINGLESTEP it will 782 finish the syscall but PC will not change. 783 784 Some vDSOs contain 'int $0x80; ret' and during stepping out of the syscall 785 i386_displaced_step_fixup would keep PC at the displaced pad location. 786 As PC is pointing to the 'ret' instruction before the step 787 i386_displaced_step_fixup would expect inferior has just executed that 'ret' 788 and PC should not be adjusted. In reality it finished syscall instead and 789 PC should get relocated back to its vDSO address. Hide the 'ret' 790 instruction by 'nop' so that i386_displaced_step_fixup is not confused. 791 792 It is not fully correct as the bytes in struct displaced_step_closure will 793 not match the inferior code. But we would need some new flag in 794 displaced_step_closure otherwise to keep the state that syscall is finishing 795 for the later i386_displaced_step_fixup execution as the syscall execution 796 is already no longer detectable there. The new flag field would mean 797 i386-linux-tdep.c needs to wrap all the displacement methods of i386-tdep.c 798 which does not seem worth it. The same effect is achieved by patching that 799 'nop' instruction there instead. */ 800 801 static struct displaced_step_closure * 802 i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, 803 CORE_ADDR from, CORE_ADDR to, 804 struct regcache *regs) 805 { 806 displaced_step_closure *closure_ 807 = i386_displaced_step_copy_insn (gdbarch, from, to, regs); 808 809 if (i386_linux_get_syscall_number_from_regcache (regs) != -1) 810 { 811 /* The closure returned by i386_displaced_step_copy_insn is simply a 812 buffer with a copy of the instruction. */ 813 i386_displaced_step_closure *closure 814 = (i386_displaced_step_closure *) closure_; 815 816 /* Fake nop. */ 817 closure->buf[0] = 0x90; 818 } 819 820 return closure_; 821 } 822 823 static void 824 i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) 825 { 826 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); 827 const struct target_desc *tdesc = info.target_desc; 828 struct tdesc_arch_data *tdesc_data = info.tdesc_data; 829 const struct tdesc_feature *feature; 830 int valid_p; 831 832 gdb_assert (tdesc_data); 833 834 linux_init_abi (info, gdbarch); 835 836 /* GNU/Linux uses ELF. */ 837 i386_elf_init_abi (info, gdbarch); 838 839 /* Reserve a number for orig_eax. */ 840 set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS); 841 842 if (! tdesc_has_registers (tdesc)) 843 tdesc = i386_linux_read_description (X86_XSTATE_SSE_MASK); 844 tdep->tdesc = tdesc; 845 846 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); 847 if (feature == NULL) 848 return; 849 850 valid_p = tdesc_numbered_register (feature, tdesc_data, 851 I386_LINUX_ORIG_EAX_REGNUM, 852 "orig_eax"); 853 if (!valid_p) 854 return; 855 856 /* Add the %orig_eax register used for syscall restarting. */ 857 set_gdbarch_write_pc (gdbarch, i386_linux_write_pc); 858 859 tdep->register_reggroup_p = i386_linux_register_reggroup_p; 860 861 tdep->gregset_reg_offset = i386_linux_gregset_reg_offset; 862 tdep->gregset_num_regs = ARRAY_SIZE (i386_linux_gregset_reg_offset); 863 tdep->sizeof_gregset = 17 * 4; 864 865 tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */ 866 867 tdep->sigtramp_p = i386_linux_sigtramp_p; 868 tdep->sigcontext_addr = i386_linux_sigcontext_addr; 869 tdep->sc_reg_offset = i386_linux_sc_reg_offset; 870 tdep->sc_num_regs = ARRAY_SIZE (i386_linux_sc_reg_offset); 871 872 tdep->xsave_xcr0_offset = I386_LINUX_XSAVE_XCR0_OFFSET; 873 874 set_gdbarch_process_record (gdbarch, i386_process_record); 875 set_gdbarch_process_record_signal (gdbarch, i386_linux_record_signal); 876 877 /* Initialize the i386_linux_record_tdep. */ 878 /* These values are the size of the type that will be used in a system 879 call. They are obtained from Linux Kernel source. */ 880 i386_linux_record_tdep.size_pointer 881 = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT; 882 i386_linux_record_tdep.size__old_kernel_stat = 32; 883 i386_linux_record_tdep.size_tms = 16; 884 i386_linux_record_tdep.size_loff_t = 8; 885 i386_linux_record_tdep.size_flock = 16; 886 i386_linux_record_tdep.size_oldold_utsname = 45; 887 i386_linux_record_tdep.size_ustat = 20; 888 i386_linux_record_tdep.size_old_sigaction = 16; 889 i386_linux_record_tdep.size_old_sigset_t = 4; 890 i386_linux_record_tdep.size_rlimit = 8; 891 i386_linux_record_tdep.size_rusage = 72; 892 i386_linux_record_tdep.size_timeval = 8; 893 i386_linux_record_tdep.size_timezone = 8; 894 i386_linux_record_tdep.size_old_gid_t = 2; 895 i386_linux_record_tdep.size_old_uid_t = 2; 896 i386_linux_record_tdep.size_fd_set = 128; 897 i386_linux_record_tdep.size_old_dirent = 268; 898 i386_linux_record_tdep.size_statfs = 64; 899 i386_linux_record_tdep.size_statfs64 = 84; 900 i386_linux_record_tdep.size_sockaddr = 16; 901 i386_linux_record_tdep.size_int 902 = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT; 903 i386_linux_record_tdep.size_long 904 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT; 905 i386_linux_record_tdep.size_ulong 906 = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT; 907 i386_linux_record_tdep.size_msghdr = 28; 908 i386_linux_record_tdep.size_itimerval = 16; 909 i386_linux_record_tdep.size_stat = 88; 910 i386_linux_record_tdep.size_old_utsname = 325; 911 i386_linux_record_tdep.size_sysinfo = 64; 912 i386_linux_record_tdep.size_msqid_ds = 88; 913 i386_linux_record_tdep.size_shmid_ds = 84; 914 i386_linux_record_tdep.size_new_utsname = 390; 915 i386_linux_record_tdep.size_timex = 128; 916 i386_linux_record_tdep.size_mem_dqinfo = 24; 917 i386_linux_record_tdep.size_if_dqblk = 68; 918 i386_linux_record_tdep.size_fs_quota_stat = 68; 919 i386_linux_record_tdep.size_timespec = 8; 920 i386_linux_record_tdep.size_pollfd = 8; 921 i386_linux_record_tdep.size_NFS_FHSIZE = 32; 922 i386_linux_record_tdep.size_knfsd_fh = 132; 923 i386_linux_record_tdep.size_TASK_COMM_LEN = 16; 924 i386_linux_record_tdep.size_sigaction = 20; 925 i386_linux_record_tdep.size_sigset_t = 8; 926 i386_linux_record_tdep.size_siginfo_t = 128; 927 i386_linux_record_tdep.size_cap_user_data_t = 12; 928 i386_linux_record_tdep.size_stack_t = 12; 929 i386_linux_record_tdep.size_off_t = i386_linux_record_tdep.size_long; 930 i386_linux_record_tdep.size_stat64 = 96; 931 i386_linux_record_tdep.size_gid_t = 4; 932 i386_linux_record_tdep.size_uid_t = 4; 933 i386_linux_record_tdep.size_PAGE_SIZE = 4096; 934 i386_linux_record_tdep.size_flock64 = 24; 935 i386_linux_record_tdep.size_user_desc = 16; 936 i386_linux_record_tdep.size_io_event = 32; 937 i386_linux_record_tdep.size_iocb = 64; 938 i386_linux_record_tdep.size_epoll_event = 12; 939 i386_linux_record_tdep.size_itimerspec 940 = i386_linux_record_tdep.size_timespec * 2; 941 i386_linux_record_tdep.size_mq_attr = 32; 942 i386_linux_record_tdep.size_termios = 36; 943 i386_linux_record_tdep.size_termios2 = 44; 944 i386_linux_record_tdep.size_pid_t = 4; 945 i386_linux_record_tdep.size_winsize = 8; 946 i386_linux_record_tdep.size_serial_struct = 60; 947 i386_linux_record_tdep.size_serial_icounter_struct = 80; 948 i386_linux_record_tdep.size_hayes_esp_config = 12; 949 i386_linux_record_tdep.size_size_t = 4; 950 i386_linux_record_tdep.size_iovec = 8; 951 i386_linux_record_tdep.size_time_t = 4; 952 953 /* These values are the second argument of system call "sys_ioctl". 954 They are obtained from Linux Kernel source. */ 955 i386_linux_record_tdep.ioctl_TCGETS = 0x5401; 956 i386_linux_record_tdep.ioctl_TCSETS = 0x5402; 957 i386_linux_record_tdep.ioctl_TCSETSW = 0x5403; 958 i386_linux_record_tdep.ioctl_TCSETSF = 0x5404; 959 i386_linux_record_tdep.ioctl_TCGETA = 0x5405; 960 i386_linux_record_tdep.ioctl_TCSETA = 0x5406; 961 i386_linux_record_tdep.ioctl_TCSETAW = 0x5407; 962 i386_linux_record_tdep.ioctl_TCSETAF = 0x5408; 963 i386_linux_record_tdep.ioctl_TCSBRK = 0x5409; 964 i386_linux_record_tdep.ioctl_TCXONC = 0x540A; 965 i386_linux_record_tdep.ioctl_TCFLSH = 0x540B; 966 i386_linux_record_tdep.ioctl_TIOCEXCL = 0x540C; 967 i386_linux_record_tdep.ioctl_TIOCNXCL = 0x540D; 968 i386_linux_record_tdep.ioctl_TIOCSCTTY = 0x540E; 969 i386_linux_record_tdep.ioctl_TIOCGPGRP = 0x540F; 970 i386_linux_record_tdep.ioctl_TIOCSPGRP = 0x5410; 971 i386_linux_record_tdep.ioctl_TIOCOUTQ = 0x5411; 972 i386_linux_record_tdep.ioctl_TIOCSTI = 0x5412; 973 i386_linux_record_tdep.ioctl_TIOCGWINSZ = 0x5413; 974 i386_linux_record_tdep.ioctl_TIOCSWINSZ = 0x5414; 975 i386_linux_record_tdep.ioctl_TIOCMGET = 0x5415; 976 i386_linux_record_tdep.ioctl_TIOCMBIS = 0x5416; 977 i386_linux_record_tdep.ioctl_TIOCMBIC = 0x5417; 978 i386_linux_record_tdep.ioctl_TIOCMSET = 0x5418; 979 i386_linux_record_tdep.ioctl_TIOCGSOFTCAR = 0x5419; 980 i386_linux_record_tdep.ioctl_TIOCSSOFTCAR = 0x541A; 981 i386_linux_record_tdep.ioctl_FIONREAD = 0x541B; 982 i386_linux_record_tdep.ioctl_TIOCINQ = i386_linux_record_tdep.ioctl_FIONREAD; 983 i386_linux_record_tdep.ioctl_TIOCLINUX = 0x541C; 984 i386_linux_record_tdep.ioctl_TIOCCONS = 0x541D; 985 i386_linux_record_tdep.ioctl_TIOCGSERIAL = 0x541E; 986 i386_linux_record_tdep.ioctl_TIOCSSERIAL = 0x541F; 987 i386_linux_record_tdep.ioctl_TIOCPKT = 0x5420; 988 i386_linux_record_tdep.ioctl_FIONBIO = 0x5421; 989 i386_linux_record_tdep.ioctl_TIOCNOTTY = 0x5422; 990 i386_linux_record_tdep.ioctl_TIOCSETD = 0x5423; 991 i386_linux_record_tdep.ioctl_TIOCGETD = 0x5424; 992 i386_linux_record_tdep.ioctl_TCSBRKP = 0x5425; 993 i386_linux_record_tdep.ioctl_TIOCTTYGSTRUCT = 0x5426; 994 i386_linux_record_tdep.ioctl_TIOCSBRK = 0x5427; 995 i386_linux_record_tdep.ioctl_TIOCCBRK = 0x5428; 996 i386_linux_record_tdep.ioctl_TIOCGSID = 0x5429; 997 i386_linux_record_tdep.ioctl_TCGETS2 = 0x802c542a; 998 i386_linux_record_tdep.ioctl_TCSETS2 = 0x402c542b; 999 i386_linux_record_tdep.ioctl_TCSETSW2 = 0x402c542c; 1000 i386_linux_record_tdep.ioctl_TCSETSF2 = 0x402c542d; 1001 i386_linux_record_tdep.ioctl_TIOCGPTN = 0x80045430; 1002 i386_linux_record_tdep.ioctl_TIOCSPTLCK = 0x40045431; 1003 i386_linux_record_tdep.ioctl_FIONCLEX = 0x5450; 1004 i386_linux_record_tdep.ioctl_FIOCLEX = 0x5451; 1005 i386_linux_record_tdep.ioctl_FIOASYNC = 0x5452; 1006 i386_linux_record_tdep.ioctl_TIOCSERCONFIG = 0x5453; 1007 i386_linux_record_tdep.ioctl_TIOCSERGWILD = 0x5454; 1008 i386_linux_record_tdep.ioctl_TIOCSERSWILD = 0x5455; 1009 i386_linux_record_tdep.ioctl_TIOCGLCKTRMIOS = 0x5456; 1010 i386_linux_record_tdep.ioctl_TIOCSLCKTRMIOS = 0x5457; 1011 i386_linux_record_tdep.ioctl_TIOCSERGSTRUCT = 0x5458; 1012 i386_linux_record_tdep.ioctl_TIOCSERGETLSR = 0x5459; 1013 i386_linux_record_tdep.ioctl_TIOCSERGETMULTI = 0x545A; 1014 i386_linux_record_tdep.ioctl_TIOCSERSETMULTI = 0x545B; 1015 i386_linux_record_tdep.ioctl_TIOCMIWAIT = 0x545C; 1016 i386_linux_record_tdep.ioctl_TIOCGICOUNT = 0x545D; 1017 i386_linux_record_tdep.ioctl_TIOCGHAYESESP = 0x545E; 1018 i386_linux_record_tdep.ioctl_TIOCSHAYESESP = 0x545F; 1019 i386_linux_record_tdep.ioctl_FIOQSIZE = 0x5460; 1020 1021 /* These values are the second argument of system call "sys_fcntl" 1022 and "sys_fcntl64". They are obtained from Linux Kernel source. */ 1023 i386_linux_record_tdep.fcntl_F_GETLK = 5; 1024 i386_linux_record_tdep.fcntl_F_GETLK64 = 12; 1025 i386_linux_record_tdep.fcntl_F_SETLK64 = 13; 1026 i386_linux_record_tdep.fcntl_F_SETLKW64 = 14; 1027 1028 i386_linux_record_tdep.arg1 = I386_EBX_REGNUM; 1029 i386_linux_record_tdep.arg2 = I386_ECX_REGNUM; 1030 i386_linux_record_tdep.arg3 = I386_EDX_REGNUM; 1031 i386_linux_record_tdep.arg4 = I386_ESI_REGNUM; 1032 i386_linux_record_tdep.arg5 = I386_EDI_REGNUM; 1033 i386_linux_record_tdep.arg6 = I386_EBP_REGNUM; 1034 1035 tdep->i386_intx80_record = i386_linux_intx80_sysenter_syscall_record; 1036 tdep->i386_sysenter_record = i386_linux_intx80_sysenter_syscall_record; 1037 tdep->i386_syscall_record = i386_linux_intx80_sysenter_syscall_record; 1038 1039 /* N_FUN symbols in shared libaries have 0 for their values and need 1040 to be relocated. */ 1041 set_gdbarch_sofun_address_maybe_missing (gdbarch, 1); 1042 1043 /* GNU/Linux uses SVR4-style shared libraries. */ 1044 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); 1045 set_solib_svr4_fetch_link_map_offsets 1046 (gdbarch, svr4_ilp32_fetch_link_map_offsets); 1047 1048 /* GNU/Linux uses the dynamic linker included in the GNU C Library. */ 1049 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver); 1050 1051 dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p); 1052 1053 /* Enable TLS support. */ 1054 set_gdbarch_fetch_tls_load_module_address (gdbarch, 1055 svr4_fetch_objfile_link_map); 1056 1057 /* Core file support. */ 1058 set_gdbarch_iterate_over_regset_sections 1059 (gdbarch, i386_linux_iterate_over_regset_sections); 1060 set_gdbarch_core_read_description (gdbarch, 1061 i386_linux_core_read_description); 1062 1063 /* Displaced stepping. */ 1064 set_gdbarch_displaced_step_copy_insn (gdbarch, 1065 i386_linux_displaced_step_copy_insn); 1066 set_gdbarch_displaced_step_fixup (gdbarch, i386_displaced_step_fixup); 1067 set_gdbarch_displaced_step_location (gdbarch, 1068 linux_displaced_step_location); 1069 1070 /* Functions for 'catch syscall'. */ 1071 set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386); 1072 set_gdbarch_get_syscall_number (gdbarch, 1073 i386_linux_get_syscall_number); 1074 1075 set_gdbarch_get_siginfo_type (gdbarch, x86_linux_get_siginfo_type); 1076 set_gdbarch_handle_segmentation_fault (gdbarch, 1077 i386_linux_handle_segmentation_fault); 1078 } 1079 1080 void 1081 _initialize_i386_linux_tdep (void) 1082 { 1083 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX, 1084 i386_linux_init_abi); 1085 1086 #if GDB_SELF_TEST 1087 struct 1088 { 1089 const char *xml; 1090 uint64_t mask; 1091 } xml_masks[] = { 1092 { "i386/i386-linux.xml", X86_XSTATE_SSE_MASK }, 1093 { "i386/i386-mmx-linux.xml", X86_XSTATE_X87_MASK }, 1094 { "i386/i386-avx-linux.xml", X86_XSTATE_AVX_MASK }, 1095 { "i386/i386-mpx-linux.xml", X86_XSTATE_MPX_MASK }, 1096 { "i386/i386-avx-mpx-linux.xml", X86_XSTATE_AVX_MPX_MASK }, 1097 { "i386/i386-avx-avx512-linux.xml", X86_XSTATE_AVX_AVX512_MASK }, 1098 { "i386/i386-avx-mpx-avx512-pku-linux.xml", 1099 X86_XSTATE_AVX_MPX_AVX512_PKU_MASK }, 1100 }; 1101 1102 for (auto &a : xml_masks) 1103 { 1104 auto tdesc = i386_linux_read_description (a.mask); 1105 1106 selftests::record_xml_tdesc (a.xml, tdesc); 1107 } 1108 #endif /* GDB_SELF_TEST */ 1109 } 1110