When we do a "new" in C++ we call an operator function with "new" being the keyword that the C++ compiler understands.
Also when C++ compiler see a "new" is the following correct (broad sense)
1. It would make a symbol table entry for the token being new'ed
2. It would assign it a (relocatable) address within that .o file
3. All -> operators on the new would be in assembly referring to that address
4. If the size is 100 bytes it would somewhere store how many bytes there is, maybe in the previous memory block. This is compiler dependent (needs clarification??) It calls the OS malloc call with the size needed.
When delete is called
- It will call system call free passing it the size and the pointer to be marked free.
That is what I gathered in the very broad sense. Please chime in with your comments on the above work-flow.
Some of your details aren't quite right because you are confusing some functionality that the compiler provides at compile time vs. what the OS provides at runtime.
1. No. The symbol table, in the compiler, is a list of all the user-defined identifiers the compiler has seen. "new Foo;" does not create a new entry for Foo, because the compiler must have seen the "Foo" symbol already (and have already added it) otherwise a compile error occurs.
2. No. "new <anything>;" allocates memory on the heap at runtime. No part of a .o file consists of the heap; it is created at runtime by the OS.
Last item -- free() is not a system call; it is a function in the C library.