| 329 | // |
| 330 | |
| 331 | STATIC |
| 332 | VOID |
| 333 | ScanSections32 ( |
| 334 | VOID |
| 335 | ) |
| 336 | { |
| 337 | UINT32 i; |
| 338 | EFI_IMAGE_DOS_HEADER *DosHdr; |
| 339 | EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr; |
| 340 | UINT32 CoffEntry; |
| 341 | UINT32 SectionCount; |
| 342 | BOOLEAN FoundSection; |
| 343 | |
| 344 | CoffEntry = 0; |
| 345 | mCoffOffset = 0; |
| 346 | |
| 347 | // |
| 348 | // Coff file start with a DOS header. |
| 349 | // |
| 350 | mCoffOffset = sizeof(EFI_IMAGE_DOS_HEADER) + 0x40; |
| 351 | mNtHdrOffset = mCoffOffset; |
| 352 | switch (mEhdr->e_machine) { |
| 353 | case EM_386: |
| 354 | case EM_ARM: |
| 355 | mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32); |
| 356 | break; |
| 357 | default: |
| 358 | VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)mEhdr->e_machine); |
| 359 | mCoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32); |
| 360 | break; |
| 361 | } |
| 362 | |
| 363 | mTableOffset = mCoffOffset; |
| 364 | mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER); |
| 365 | |
| 366 | // |
| 367 | // Set mCoffAlignment to the maximum alignment of the input sections |
| 368 | // we care about |
| 369 | // |
| 370 | for (i = 0; i < mEhdr->e_shnum; i++) { |
| 371 | Elf_Shdr *shdr = GetShdrByIndex(i); |
| 372 | if (shdr->sh_addralign <= mCoffAlignment) { |
| 373 | continue; |
| 374 | } |
| 375 | if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) { |
| 376 | mCoffAlignment = (UINT32)shdr->sh_addralign; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | // |
| 381 | // Check if mCoffAlignment is larger than MAX_COFF_ALIGNMENT |
| 382 | // |
| 383 | if (mCoffAlignment > MAX_COFF_ALIGNMENT) { |
| 384 | Error (NULL, 0, 3000, "Invalid", "Section alignment is larger than MAX_COFF_ALIGNMENT."); |
| 385 | assert (FALSE); |
| 386 | } |
| 387 | |
| 388 | // |
nothing calls this directly
no test coverage detected