Shape optimization against buckling of micro- and nano- rods