1

How can I call to operator new[] with GDB?

For example I want to allocate 0x40 bytes and print the address : operator new[](0x44u));

How can I do that using GDB ?

When I tried p (void*)operator new[](0x40) I got No symbol "operator" in current context.

2
  • Does p (void*)operator new[](0x40) not work? Commented Jan 5, 2023 at 12:39
  • No symbol "operator" in current context. Commented Jan 5, 2023 at 13:38

1 Answer 1

1

This worked for me:

(gdb) p 'operator new<TAB>
operator new(unsigned long)
operator new(unsigned long) [clone .cold]
...
operator new[](unsigned long)
operator new[](unsigned long)@got.plt
operator new[](unsigned long)@plt
operator new[](unsigned long, std::align_val_t)
... more choices

(gdb) p 'operator new[](unsigned long)'(0x40)
$1 = (void *) 0x416ee0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.