
I read about this somewhere else, but I had to try it out myself...
The first two links in Microsoft Search when looking for Linux is "how to remove Linux". Elegant.
Experiences, Adventures, Appreciations, Notes, Tips, Tricks and References on using Ubuntu (sometimes Linux in general).
A 32-bit operating system is limited to 4 GB of memory ( you can only reference 2 ^ 32 = 4GB ). However, 32-bit Ubuntu is limited to 3 GB. If you are considering between 32-bit and 64-bit Ubuntu and you have more than 3 GB of memory that should be a simple decision.
There is a workaround however if you are still not convinced 64-bit is the way to go - install server kernel as it has support for upto 4 GB. But think about the future when your 4GB will not be enough and you add more memory?
When using inheritance, destructors are called in the reverse order of inheritance. If a base class pointer points to a derived class object, and later we use the delete operator to delete the object, then the derived class destructor is not called. Refer to the code that follows:
#include
class base
{
public:
~base()
{
}
};
class derived : public base
{
public:
~derived()
{
}
};
void main()
{
base *ptr = new derived();
// some code
delete ptr;
}
The result is a memory leak.
Solution to avoid this -
Make the destructor virtual in the base class. A virtual destructor is one that is declared as virtual in the base class.
#include
class base
{
public:
virtual ~base()
{
}
};
class derived : public base
{
public:
~derived()
{
}
};
void main()
{
base *ptr = new derived();
// some code
delete ptr;
}
Does this mean when using virtual functions, it is always a good idea have the destructor virtual as well?
Each ELF file is made up of one ELF header, followed by file data. The file data can include:
readelf
is a Unix binary utility that displays information about one or more ELF files.objdump
provides a wide range of information about ELF files and other object formats.
rutul@ubuntu:~/test_progs$ gcc hello_world.c
rutul@ubuntu:~/test_progs$ ldd a.out
linux-gate.so.1 => (0xb7ef2000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7d80000)
/lib/ld-linux.so.2 (0xb7ef3000)
rutul@ubuntu:~/test_progs$
rutul@ubuntu:~/test_progs$ readelf -l a.out
Elf file type is EXEC (Executable file)
Entry point 0x8048310
There are 8 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x08048034 0x08048034 0x00100 0x00100 R E 0x4
INTERP 0x000134 0x08048134 0x08048134 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.2]
LOAD 0x000000 0x08048000 0x08048000 0x004c4 0x004c4 R E 0x1000
LOAD 0x000f0c 0x08049f0c 0x08049f0c 0x00108 0x00110 RW 0x1000
DYNAMIC 0x000f20 0x08049f20 0x08049f20 0x000d0 0x000d0 RW 0x4
NOTE 0x000148 0x08048148 0x08048148 0x00020 0x00020 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4
GNU_RELRO 0x000f0c 0x08049f0c 0x08049f0c 0x000f4 0x000f4 R 0x1
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .hash .gnu.hash .dynsym .dynstr .gnu.version .gn
u.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame
03 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.ABI-tag
06
07 .ctors .dtors .jcr .dynamic .got
rutul@ubuntu:~/test_progs$