Skip to content

Commit 2d0fc79

Browse files
FlyGoathuth
authored andcommitted
elf2dmp: Rename PAGE_SIZE to ELF2DMP_PAGE_SIZE
As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. To prevent collosion of definition, we rename PAGE_SIZE here. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210118063808.12471-6-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent 9c57272 commit 2d0fc79

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

contrib/elf2dmp/addrspace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ int va_space_rw(struct va_space *vs, uint64_t addr,
207207
void *buf, size_t size, int is_write)
208208
{
209209
while (size) {
210-
uint64_t page = addr & PFN_MASK;
211-
size_t s = (page + PAGE_SIZE) - addr;
210+
uint64_t page = addr & ELF2DMP_PFN_MASK;
211+
size_t s = (page + ELF2DMP_PAGE_SIZE) - addr;
212212
void *ptr;
213213

214214
s = (s > size) ? size : s;

contrib/elf2dmp/addrspace.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
#include "qemu_elf.h"
1212

13-
#define PAGE_BITS 12
14-
#define PAGE_SIZE (1ULL << PAGE_BITS)
15-
#define PFN_MASK (~(PAGE_SIZE - 1))
13+
#define ELF2DMP_PAGE_BITS 12
14+
#define ELF2DMP_PAGE_SIZE (1ULL << ELF2DMP_PAGE_BITS)
15+
#define ELF2DMP_PFN_MASK (~(ELF2DMP_PAGE_SIZE - 1))
1616

1717
#define INVALID_PA UINT64_MAX
1818

contrib/elf2dmp/main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps,
244244
WinDumpHeader64 h;
245245
size_t i;
246246

247-
QEMU_BUILD_BUG_ON(KUSD_OFFSET_SUITE_MASK >= PAGE_SIZE);
248-
QEMU_BUILD_BUG_ON(KUSD_OFFSET_PRODUCT_TYPE >= PAGE_SIZE);
247+
QEMU_BUILD_BUG_ON(KUSD_OFFSET_SUITE_MASK >= ELF2DMP_PAGE_SIZE);
248+
QEMU_BUILD_BUG_ON(KUSD_OFFSET_PRODUCT_TYPE >= ELF2DMP_PAGE_SIZE);
249249

250250
if (!suite_mask || !product_type) {
251251
return 1;
@@ -281,14 +281,14 @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps,
281281
};
282282

283283
for (i = 0; i < ps->block_nr; i++) {
284-
h.PhysicalMemoryBlock.NumberOfPages += ps->block[i].size / PAGE_SIZE;
284+
h.PhysicalMemoryBlock.NumberOfPages += ps->block[i].size / ELF2DMP_PAGE_SIZE;
285285
h.PhysicalMemoryBlock.Run[i] = (WinDumpPhyMemRun64) {
286-
.BasePage = ps->block[i].paddr / PAGE_SIZE,
287-
.PageCount = ps->block[i].size / PAGE_SIZE,
286+
.BasePage = ps->block[i].paddr / ELF2DMP_PAGE_SIZE,
287+
.PageCount = ps->block[i].size / ELF2DMP_PAGE_SIZE,
288288
};
289289
}
290290

291-
h.RequiredDumpSpace += h.PhysicalMemoryBlock.NumberOfPages << PAGE_BITS;
291+
h.RequiredDumpSpace += h.PhysicalMemoryBlock.NumberOfPages << ELF2DMP_PAGE_BITS;
292292

293293
*hdr = h;
294294

@@ -379,7 +379,7 @@ static int pe_get_pdb_symstore_hash(uint64_t base, void *start_addr,
379379
size_t pdb_name_sz;
380380
size_t i;
381381

382-
QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= PAGE_SIZE);
382+
QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= ELF2DMP_PAGE_SIZE);
383383

384384
if (memcmp(&dos_hdr->e_magic, e_magic, sizeof(e_magic))) {
385385
return 1;
@@ -509,10 +509,10 @@ int main(int argc, char *argv[])
509509
}
510510
printf("CPU #0 IDT[0] -> 0x%016"PRIx64"\n", idt_desc_addr(first_idt_desc));
511511

512-
KernBase = idt_desc_addr(first_idt_desc) & ~(PAGE_SIZE - 1);
512+
KernBase = idt_desc_addr(first_idt_desc) & ~(ELF2DMP_PAGE_SIZE - 1);
513513
printf("Searching kernel downwards from 0x%016"PRIx64"...\n", KernBase);
514514

515-
for (; KernBase >= 0xfffff78000000000; KernBase -= PAGE_SIZE) {
515+
for (; KernBase >= 0xfffff78000000000; KernBase -= ELF2DMP_PAGE_SIZE) {
516516
nt_start_addr = va_space_resolve(&vs, KernBase);
517517
if (!nt_start_addr) {
518518
continue;

0 commit comments

Comments
 (0)